#include <iostream>
using namespace std;
int main()
{
int n;
string s;
cin >> n;
while (n--)
{
cin >> s;
int a = 1, b = 1, c = 1, d = 1;
for (int i = 0; i < s.size(); i++)
{
if (s[i] > '1')
a = 0;
if (s[i] > '7')
b = 0;
if (s[i] > '9')
c = 0;
if (s[i] > 'F')
d = 0;
}
cout << a << " " << b << " " << c << " " << d << '\n';
}
return 0;
}