// NOTE: it is recommended to use this even if you don't understand the following code.
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <limits> // Szükséges a numeric_limits használatához
using namespace std;
int main() {
// uncomment the two following lines if you want to read/write from files
// ifstream cin("input.txt");
// ofstream cout("output.txt");
string W;
long long N, M,a,x;
int T;
cin >> T;
for (int test = 1; test <= T; ++test) {
cin >> N >> M;
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
// INSERT YOUR CODE HERE
if(N<5){
if(M<N) W="tommaso";
else if (M=N) W="draw";
else W="filippo";
}
else{
a = N/2;
x = N-a;
if(x>=M) W="tommaso";
else if(x+1==M) W="draw";
else W="filippo";
}
cout << W << endl;
}
return 0;
}