package BOJ.DP;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* BOJ 1003
* https://www.acmicpc.net/problem/1003
*/
public class FibonacciFunction_1003 {
private static int[] arr = new int[40+1];
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int count = Integer.parseInt(br.readLine());
arr[0]=0;
arr[1]=1;
while(count-- >0){
int n = Integer.parseInt(br.readLine());
fibonacci(n);
// n=0
if(n == 0)
System.out.println(arr[1]+" "+arr[0]);
// n!=0 -> f(0) 호출횟수: f(n-1) / f(1) 호출횟수: f(n)
else
System.out.println(arr[n-1]+" "+arr[n]);
}
}
private static int fibonacci(int n) {
if(n == 0){
return 0;
}
if (n == 1){
return 1;
}
if(arr[n] > 0)
return arr[n];
arr[n] = fibonacci(n-1) + fibonacci(n-2);
return arr[n];
}
}