import java.util.*
var arr = arrayListOf<Pair<Int,Int>>()
fun main() = with(Scanner(System.`in`)){
var t = nextInt()
var tmp = 0
arr.add(1 to 0)
arr.add(0 to 1)
for(i in 2 .. 40){
arr.add(arr[i-1].first+arr[i-2].first to arr[i-1].second+arr[i-2].second)
}
for(i in 0 until t){
tmp = nextInt()
println("${arr[tmp].first} ${arr[tmp].second}")
}
}