#include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          int lastAnswer=0,t,x,y,q,n,temp;
          cin>>n>>q;
          vector <vector<int>> seq(n);
          for(int i=0;i<q;i++)
          {
              cin>>t>>x>>y;
              temp = (x^lastAnswer)%n;
              if(t==1)
                  seq.at(temp).push_back(y);
              else
              {
                  lastAnswer = y%seq.at(temp).size();
                  lastAnswer = seq.at(temp).at(lastAnswer);
                  cout<<lastAnswer<<"\n";
              }   
          }
          return 0;
      }
      
      Cpp language logo

      Dynamic array

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.