import std.stdio, std.conv, std.string, std.range, std.math, std.algorithm; void main() { auto input = readln.split.to!(ulong[]); auto F0 = input[0], F1 = input[1], N = input[2]; recurrence!"a[n-1]^a[n-2]"(F0, F1).take(N % 3 + 1).array.back.writeln; }