import std.algorithm, std.array, std.conv, std.stdio, std.typecons;

auto solve(long A, long B) {
	auto c = new long[B+1];
	c[B] = A;
	auto i = 0;
	while (i <= B-2) {
		c[B-i-1] -= c[B-i];
		c[B-i-2] -= c[B-i];
		i += 1;
	}
	return tuple(c[1], c[0]);
}

void main() {
	auto AB = readln.split.to!(long[]);
	if (AB[1] == 0) writeln("0 ", AB[0]);
	else if (AB[1] == 1) writeln(AB[0], " 0");
	else {
		auto ans = solve(AB[0], AB[1]);
		writeln(ans[0], " ", ans[1]);
	}
}