import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int Q = sc.nextInt();
int lastAns = 0;
int tag, x, y, index;
ArrayList<Integer>[] list = new ArrayList[N];
while(Q-->0){
tag = sc.nextInt();
x = sc.nextInt();
y = sc.nextInt();
index = (x^lastAns)%N;
switch(tag){
case 1:
if(list[index] == null){
ArrayList<Integer> myList = new ArrayList<>();
myList.add(y);
list[index] = myList;
}else{
list[index].add(y);
}
break;
case 2:
System.out.println(lastAns = list[index].get(y % list[index].size()));
break;
}
}
}
}
Last active
June 19, 2016 03:13
-
-
Save igaozp/daf773df902a690f0a0560b8ba3e92e9 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment