#include <cstdio>
using namespace std;

int main() {
    int n, j; scanf("%d", &n);
    if (n>1000) return 0;
    char s[334][17]={
    "2021212120212020",
    "2121202120212021",
    "2120212120202121",
    "2121202120202121",
    "2021212020212120",
    "2120202021212020",
    "2120202120212021",
    "2021212021202021",
    "2121202120202020",
    "2121212121202120",
    "2120202021202021",
    "2120202120212020",
    "2020202121212021",
    "2021202120212021",
    "2020212121212020",
    "2020212120202120",
    "2020202021212021",
    "2021212020202121",
    "2020202121212120",
    "2121212121202020",
    "2120202121212120",
    "2121212120212121",
    "2120212021212020",
    "2120202021212021",
    "2120212020202121",
    "2020202020202121",
    "2021202120202020",
    "2020202121212121",
    "2020212121202021",
    "2120212020202020",
    "2121202120202121",
    "2020212020212021",
    "2121202121202021",
    "2120212020202020",
    "2120212121212121",
    "2021212121202121",
    "2020202121212021",
    "2120202120202120",
    "2121202120202120",
    "2021202020212021",
    "2120212020212120",
    "2120212020202120",
    "2121212020202020",
    "2021212020212021",
    "2020212120212120",
    "2120202021212120",
    "2121202120212121",
    "2121212021202120",
    "2020212121202121",
    "2120212020212121",
    "2020212020212020",
    "2021202121202021",
    "2120202120212021",
    "2020202021202121",
    "2020202021202120",
    "2121202121212021",
    "2120202121202021",
    "2120212020212121",
    "2021202020202020",
    "2120202120202120",
    "2020202120202021",
    "2120202020202021",
    "2121202120202121",
    "2120202121202020",
    "2121212120212120",
    "2020202021202021",
    "2021212020202120",
    "2021202121212020",
    "2021202021212021",
    "2021202121212120",
    "2120212120212121",
    "2020202021202020",
    "2120212121202120",
    "2121202021202021",
    "2120212121212020",
    "2021212120202120",
    "2021212121202121",
    "2120212120212120",
    "2021202121212120",
    "2021202121212021",
    "2120202021212120",
    "2021212021212121",
    "2121202021202021",
    "2121212020212121",
    "2020212120202120",
    "2021212021212120",
    "2120202020202021",
    "2020212121202120",
    "2020212020212021",
    "2020212120212120",
    "2021202121212121",
    "2120212021212121",
    "2120202121202121",
    "2020212021202021",
    "2120212120202121",
    "2021202021212121",
    "2121212021212021",
    "2020212120202021",
    "2120202021202120",
    "2121202021212020",
    "2021202121212120",
    "2120212020212120",
    "2120212120202020",
    "2020202121202120",
    "2121212020212021",
    "2120212120212121",
    "2121212121202021",
    "2020202121212121",
    "2121202021202121",
    "2120202021212121",
    "2121202021212121",
    "2121202020202020",
    "2120202121212020",
    "2021212120202120",
    "2020202021202120",
    "2121212020202121",
    "2021212121202021",
    "2021202020212121",
    "2021212021202120",
    "2020202020202020",
    "2120212120202121",
    "2120202120212020",
    "2020202121212120",
    "2021202020202021",
    "2121212121212020",
    "2021212021202020",
    "2120212021212120",
    "2120202021202020",
    "2020202121202121",
    "2021212120202021",
    "2020212121202120",
    "2120202021212120",
    "2121202121212120",
    "2121202121212021",
    "2020212120212121",
    "2120202121202020",
    "2120202120212021",
    "2120202120212121",
    "2121202121212121",
    "2120202121212020",
    "2120212021202021",
    "2120212021202020",
    "2020212021212120",
    "2120212020202120",
    "2020212021202121",
    "2021212021212120",
    "2021212021202020",
    "2020202121202021",
    "2121202120202120",
    "2120202021212121",
    "2121202120212020",
    "2121212120212020",
    "2021202120202121",
    "2020202121212020",
    "2021212020202121",
    "2020202021212120",
    "2120212121212021",
    "2021212020212020",
    "2121212020212121",
    "2020212120212020",
    "2020202121202120",
    "2021212121202020",
    "2120202121212121",
    "2121202021202021",
    "2120202020212121",
    "2021212121202121",
    "2021212121212121",
    "2121202020212020",
    "2121212121202120",
    "2020202020212021",
    "2120202121202021",
    "2021212021202120",
    "2121202021202120",
    "2021202020202120",
    "2121202120212020",
    "2121202020202121",
    "2020202121202021",
    "2021212120202120",
    "2121202021212020",
    "2020212021202120",
    "2120202120212020",
    "2120212021212121",
    "2020202120212020",
    "2121212020212120",
    "2021202120212020",
    "2021212021212020",
    "2121212121212120",
    "2021202020212020",
    "2120212020212020",
    "2021212121202021",
    "2121212121212020",
    "2021212020212121",
    "2021212121202020",
    "2121202021212121",
    "2020202120212021",
    "2120202121202021",
    "2120202121212121",
    "2120212121212020",
    "2120212121212020",
    "2121202020202120",
    "2120202021212021",
    "2121212121212120",
    "2020202020212020",
    "2021202120212020",
    "2121202021202020",
    "2020212020202020",
    "2020202021202121",
    "2121202121202121",
    "2021212020202021",
    "2121202021202020",
    "2120212020202121",
    "2020202121212121",
    "2120212021202120",
    "2121212120212120",
    "2021212121212120",
    "2021212120212121",
    "2121212020212120",
    "2120202121202020",
    "2120212121202020",
    "2120202120202120",
    "2120212121202120",
    "2021202020212120",
    "2020212121202120",
    "2021202021202021",
    "2121202021202121",
    "2020202120202120",
    "2021212120202121",
    "2120212120202021",
    "2020202021212120",
    "2120202020202121",
    "2021202121212121",
    "2120202121202020",
    "2021212120202021",
    "2020212021212121",
    "2020202121212021",
    "2120212021202120",
    "2021212120202121",
    "2120202121212021",
    "2020202120202021",
    "2021202021202120",
    "2121212120212121",
    "2021202021202121",
    "2120202021212120",
    "2120202020212121",
    "2120212020202121",
    "2020212021202021",
    "2020202020212120",
    "2021202020212121",
    "2121212120202120",
    "2120212020202020",
    "2020212120212121",
    "2121212020212120",
    "2020212121202121",
    "2021202121202020",
    "2021212021202021",
    "2020212021202021",
    "2121212121212121",
    "2121202021202121",
    "2021212120202020",
    "2020212021202120",
    "2021202121212120",
    "2020202120212021",
    "2020202120212020",
    "2121202121202121",
    "2121202120202120",
    "2020202120212021",
    "2121202020212120",
    "2120212120212020",
    "2021212121212121",
    "2021202021212121",
    "2120212021212121",
    "2021202021202120",
    "2121212021212021",
    "2020212121202121",
    "2021212021202020",
    "2021212120202021",
    "2120212121202020",
    "2020212021202120",
    "2121212020202121",
    "2121202120202121",
    "2120202020202021",
    "2120212121212121",
    "2121212020212021",
    "2021202021202021",
    "2021212121212121",
    "2021202021212021",
    "2020202120202021",
    "2121202121212020",
    "2120212021212021",
    "2021202121202121",
    "2021212121212021",
    "2121202121212020",
    "2021202120202121",
    "2020202020202121",
    "2020202021212020",
    "2121212021202121",
    "2120212121212121",
    "2121202120212020",
    "2020202121212021",
    "2020202021202021",
    "2120212120212120",
    "2121202021202121",
    "2121212021212120",
    "2121202020212021",
    "2121202020202020",
    "2120212120202020",
    "2121212021212021",
    "2021212120202121",
    "2120202120202121",
    "2021212120212120",
    "2021202021212021",
    "2020212021212020",
    "2020202021212020",
    "2120212120202021",
    "2020202121212120",
    "2121202020212121",
    "2020202120202020",
    "2120202121212020",
    "2020212121202120",
    "2120202121202021",
    "2120202020202121",
    "2020212121202020",
    "2121202120212120",
    "2120212120202021",
    "2020212020202120",
    "2020202021202020",
    "2120202021202021",
    "2021212121202121",
    "2020212120212021",
    "2121202020202020",
    "2121212020212120",
    "2020212021202020",
    "2020202020202020",
    "2"};
    for (int i=0; i<n; i++) {
       scanf("%d", &j);
       printf("%s", s[j-1]);
    }
    printf("\n");
}
