def main():
    inp1 = list(map(int, input().split(" "))) 
    
    if inp1[1] == 0:
        print("0 0")
    elif inp1[1] == 1:
        print(inp1[0], end=' ')
        print("0")
    elif inp1[1] == 2:
        print("1 1")
    elif inp1[1] == 3:
        print("0", end=' ')
        print(inp1[0])
    else:
        if inp1[1] % 3 == 1:
            print(inp1[0], end=' ')
            print("0")
        elif inp1[1] % 3 == 2:
            print(-1 * inp1[0], end=' ')
            print(-1 * inp1[0])
        else:
            print(inp1[0], end=' ')
            print(inp1[0])
    
        


if __name__ == '__main__':
    main()