Ankit_132

F

Nov 17th, 2023
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  6.  
  7. int main()
  8. {
  9.     _test
  10.     {
  11.         int n, q;
  12.         cin>>n>>q;
  13.  
  14.         for(int i=1; i<n; i++)
  15.             cout<<i<<" "<<i+1<<"\n";
  16.  
  17.         int con = n-1;
  18.  
  19.         while(q--)
  20.         {
  21.             int d;
  22.             cin>>d;
  23.  
  24.             if(con == d)
  25.                 cout<<"-1 -1 -1\n";
  26.             else
  27.             {
  28.                 cout<<n<<" "<<con<<" "<<d<<"\n";
  29.                 con = d;
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment