import strutils proc nextString: string = result = "" while not endOfFile stdin: let c = readChar stdin if c == ' ' or c == "\n"[0]: return elif c != '\r': add result, c proc nextInt: int = parseInt nextString() let f0, f1, n = nextInt() f = [f0, f1, f0 xor f1] echo f[n mod 3]