import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

public class D205 implements Runnable{

    public static void main(String args[]){
       new D205().run();
    }

     public static final String INPUT_FILE = "input.in";
     public static final String OUTPUT_FILE = "output.out";

    @Override
    public void run(){
        try{
//        in = new BufferedReader(new FileReader(INPUT_FILE));
//        out = new PrintWriter(new BufferedWriter(new FileWriter(OUTPUT_FILE)));
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            tok = null;
            solve();
            in.close();
            out.close();

        }
        catch(IOException e){
            e.printStackTrace();
            System.exit(0);
        }
    }

    int nextInt()throws IOException{
        return Integer.parseInt(nextToken());
    }

    double nextDouble()throws IOException{
        return Double.parseDouble(nextToken());
    }

    long nextLong() throws IOException{
        return Long.parseLong(nextToken());
    }

    String nextToken()throws IOException{
        while(tok == null || !tok.hasMoreTokens()){
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok;
    //////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////
    int N;
    int[] front;
    int[] back;
    int needed;
    private void solve()throws IOException{
        Map<Integer, Integer> mp = new HashMap<Integer, Integer>();
        N = nextInt();
        front = new int[N];
        back = new int[N];

        for(int i = 0; i < N; i++){
            front[i] = nextInt();
            back[i] = nextInt();

        }

        for(int i = 0; i < N; i++){
        if(mp.containsKey(front[i])) mp.put(front[i], mp.get(front[i]) + 1);
            else mp.put(front[i], 1);
            if(mp.containsKey(back[i])) mp.put(back[i], mp.get(back[i]) + 1);
            else mp.put(back[i], 1);
        }

        int ans = Integer.MAX_VALUE;
        needed = (N + 1) / 2;
        for(int k : mp.keySet()){
            if(mp.get(k) >= needed){
                int now = doit(k);
                ans = Math.min(ans , now);
            }
        }

        if(ans != Integer.MAX_VALUE) out.println(ans);
        else out.println(-1);

    }//solve

    private int doit(int x){
        int f = 0, b = 0;
        for(int i = 0; i < N; i++){
            if(front[i] == x) f++; else if(back[i] == x) b++;
        }

        if(f >= needed) return 0;
        else if(f + b >= needed)return needed - f;
        return Integer.MAX_VALUE;
    }

}


import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

public class D205 implements Runnable{

    public static void main(String args[]){
       new D205().run();
    }

     public static final String INPUT_FILE = "input.in";
     public static final String OUTPUT_FILE = "output.out";

    @Override
    public void run(){
        try{
//        in = new BufferedReader(new FileReader(INPUT_FILE));
//        out = new PrintWriter(new BufferedWriter(new FileWriter(OUTPUT_FILE)));
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            tok = null;
            solve();
            in.close();
            out.close();

        }
        catch(IOException e){
            e.printStackTrace();
            System.exit(0);
        }
    }

    int nextInt()throws IOException{
        return Integer.parseInt(nextToken());
    }

    double nextDouble()throws IOException{
        return Double.parseDouble(nextToken());
    }

    long nextLong() throws IOException{
        return Long.parseLong(nextToken());
    }

    String nextToken()throws IOException{
        while(tok == null || !tok.hasMoreTokens()){
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok;
    //////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////

    private void solve()throws IOException{
      Map<Integer, Integer> front = new HashMap<Integer, Integer>();
      Map<Integer, Integer> back = new HashMap<Integer, Integer>();

      int N = nextInt();
      int needed = (N + 1) / 2;
      int ans = Integer.MAX_VALUE;

      for(int i = 0; i < N; i++){
        int f = nextInt();
        int b = nextInt();
        if(front.containsKey(f))
            front.put(f, front.get(f) + 1);
        else
            front.put(f, 1);

        if(back.containsKey(b))
             back.put(b, back.get(b) + 1);
        else
            back.put(b, 1);
      }

      for(int k : back.keySet())
          if(back.get(k) >= needed) ans = needed;

      for(int k : front.keySet()){
        if(front.get(k) >= needed) ans = 0;
        else if(back.containsKey(k) && front.get(k) + back.get(k) >= needed) ans = Math.min(ans, needed - front.get(k));
      }

      if(ans == Integer.MAX_VALUE) out.println(-1);
      else out.println(ans);

    }//solve

}


import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

public class D205 implements Runnable{

    public static void main(String args[]){
       new D205().run();
    }

     public static final String INPUT_FILE = "input.in";
     public static final String OUTPUT_FILE = "output.out";

    @Override
    public void run(){
        try{
//        in = new BufferedReader(new FileReader(INPUT_FILE));
//        out = new PrintWriter(new BufferedWriter(new FileWriter(OUTPUT_FILE)));
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            tok = null;
            solve();
            in.close();
            out.close();

        }
        catch(IOException e){
            e.printStackTrace();
            System.exit(0);
        }
    }

    int nextInt()throws IOException{
        return Integer.parseInt(nextToken());
    }

    double nextDouble()throws IOException{
        return Double.parseDouble(nextToken());
    }

    long nextLong() throws IOException{
        return Long.parseLong(nextToken());
    }

    String nextToken()throws IOException{
        while(tok == null || !tok.hasMoreTokens()){
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok;
    //////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////
    int N;
    int[] front;
    int[] back;
    int needed;
    private void solve()throws IOException{
        Map<Integer, Integer> mp = new TreeMap<Integer, Integer>();
        N = nextInt();
        front = new int[N];
        back = new int[N];

        for(int i = 0; i < N; i++){
            front[i] = nextInt();
            back[i] = nextInt();

        }

        for(int i = 0; i < N; i++){
        if(mp.containsKey(front[i])) mp.put(front[i], mp.get(front[i]) + 1);
            else mp.put(front[i], 1);
            if(mp.containsKey(back[i])) mp.put(back[i], mp.get(back[i]) + 1);
            else mp.put(back[i], 1);
        }

        int ans = Integer.MAX_VALUE;
        needed = (N + 1) / 2;
        for(int k : mp.keySet()){
            if(mp.get(k) >= needed){
                int now = doit(k);
                ans = Math.min(ans , now);
            }
        }

        if(ans != Integer.MAX_VALUE) out.println(ans);
        else out.println(-1);

    }//solve

    private int doit(int x){
        int f = 0, b = 0;
        for(int i = 0; i < N; i++){
            if(front[i] == x) f++; else if(back[i] == x) b++;
        }

        if(f >= needed) return 0;
        else if(f + b >= needed)return needed - f;
        return Integer.MAX_VALUE;
    }

}


import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

public class D205 implements Runnable{

    public static void main(String args[]){
       new D205().run();
    }

     public static final String INPUT_FILE = "input.in";
     public static final String OUTPUT_FILE = "output.out";

    @Override
    public void run(){
        try{
//        in = new BufferedReader(new FileReader(INPUT_FILE));
//        out = new PrintWriter(new BufferedWriter(new FileWriter(OUTPUT_FILE)));
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            tok = null;
            solve();
            in.close();
            out.close();

        }
        catch(IOException e){
            e.printStackTrace();
            System.exit(0);
        }
    }

    int nextInt()throws IOException{
        return Integer.parseInt(nextToken());
    }

    double nextDouble()throws IOException{
        return Double.parseDouble(nextToken());
    }

    long nextLong() throws IOException{
        return Long.parseLong(nextToken());
    }

    String nextToken()throws IOException{
        while(tok == null || !tok.hasMoreTokens()){
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok;
    //////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////
    int N;
    int[] front;
    int[] back;
    int needed;
    private void solve()throws IOException{
        Map<Integer, Integer> mp = new HashMap<Integer, Integer>();
        N = nextInt();
        front = new int[N];
        back = new int[N];

        for(int i = 0; i < N; i++){
            front[i] = nextInt();
            back[i] = nextInt();
            if(mp.containsKey(front[i])) mp.put(front[i], mp.get(front[i]) + 1);
            else mp.put(front[i], 1);
            if(mp.containsKey(back[i])) mp.put(back[i], mp.get(back[i]) + 1);
            else mp.put(back[i], 1);
        }

        int ans = Integer.MAX_VALUE;
        needed = (N + 1) / 2;
        for(int k : mp.keySet()){
            if(mp.get(k) >= needed){
                int now = doit(k);
                ans = Math.min(ans , now);
            }
        }

        if(ans != Integer.MAX_VALUE) out.println(ans);
        else out.println(-1);

    }//solve

    private int doit(int x){
        int f = 0, b = 0;
        for(int i = 0; i < N; i++){
            if(front[i] == x) f++; else if(back[i] == x) b++;
        }

        if(f >= needed) return 0;
        else if(f + b >= needed)return needed - f;
        return Integer.MAX_VALUE;
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        N = Integer.parseInt(r.readLine());

        F = new TreeMap<Integer, Integer>();
        B = new TreeMap<Integer, Integer>();
        S = new TreeSet<Integer>();

        for(int i = 0; i < N; i++){
            String[] line = r.readLine().split("[ ]+");

            int f = Integer.parseInt(line[0]);
            int b = Integer.parseInt(line[1]);

            S.add(f);S.add(b);

            if(F.containsKey(f))F.put(f, F.get(f) + 1);
            else F.put(f, 1);

            if(f != b){
                if(B.containsKey(b))B.put(b, B.get(b) + 1);
                else B.put(b, 1);
            }
        }

        int h = (N + 1) / 2;
        int min = N + 1;
        for(int c : S){
            int f = F.containsKey(c) ? F.get(c) : 0;
            int b = B.containsKey(c) ? B.get(c) : 0;

            if(f + b < h)continue;
            else min = Math.min(min, Math.max(0, h - f));
        }
        if(min == N + 1)out.println(-1);
        else out.println(min);
        out.close();
    }
    static TreeMap<Integer, Integer> F, B;
    static TreeSet<Integer> S;
    static int N;
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));

        N = Integer.parseInt(r.readLine());

        F = new HashMap<Integer, Integer>();
        B = new HashMap<Integer, Integer>();
        S = new HashSet<Integer>();

        for(int i = 0; i < N; i++){
            String[] line = r.readLine().split("[ ]+");

            int f = Integer.parseInt(line[0]);
            int b = Integer.parseInt(line[1]);

            S.add(f);S.add(b);

            if(F.containsKey(f))F.put(f, F.get(f) + 1);
            else F.put(f, 1);

            if(f != b){
                if(B.containsKey(b))B.put(b, B.get(b) + 1);
                else B.put(b, 1);
            }
        }

        int h = (N + 1) / 2;
        int min = N + 1;
        for(int c : S){
            int f = F.containsKey(c) ? F.get(c) : 0;
            int b = B.containsKey(c) ? B.get(c) : 0;

            if(f + b < h)continue;
            else min = Math.min(min, Math.max(0, h - f));
        }
        if(min == N + 1)System.out.println(-1);
        else System.out.println(min);
    }
    static HashMap<Integer, Integer> F, B;
    static HashSet<Integer> S;
    static int N;
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        N = Integer.parseInt(r.readLine());

        F = new HashMap<Integer, Integer>();
        B = new HashMap<Integer, Integer>();
        S = new HashSet<Integer>();

        for(int i = 0; i < N; i++){
            String[] line = r.readLine().split("[ ]+");

            int f = Integer.parseInt(line[0]);
            int b = Integer.parseInt(line[1]);

            S.add(f);S.add(b);

            if(F.containsKey(f))F.put(f, F.get(f) + 1);
            else F.put(f, 1);

            if(f != b){
                if(B.containsKey(b))B.put(b, B.get(b) + 1);
                else B.put(b, 1);
            }
        }

        int h = (N + 1) / 2;
        int min = N + 1;
        for(int c : S){
            int f = F.containsKey(c) ? F.get(c) : 0;
            int b = B.containsKey(c) ? B.get(c) : 0;

            if(f + b < h)continue;
            else min = Math.min(min, Math.max(0, h - f));
        }
        if(min == N + 1)out.println(-1);
        else out.println(min);
        out.close();
    }
    static HashMap<Integer, Integer> F, B;
    static HashSet<Integer> S;
    static int N;
}


import java.util.HashMap;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;

public class Project {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int a = (int)(Math.ceil((float)n / 2.0));

        sc.nextLine();

        HashMap<Integer, Integer> colorsShown = new HashMap<Integer, Integer>();
        HashMap<Integer, Integer> colorsHidden = new HashMap<Integer, Integer>();

        for (int i = 0; i < n; i++) {
            String str = sc.nextLine();
            String[] strArr = str.split(" ");

            int shownColor = Integer.parseInt(strArr[0]);
            int hiddenColor = Integer.parseInt(strArr[1]);

            if (colorsShown.containsKey(shownColor)) {
                colorsShown.put(shownColor, colorsShown.get(shownColor) + 1);
            } else {
                colorsShown.put(shownColor, 1);
            }

            if (shownColor == hiddenColor) continue;

            if (colorsHidden.containsKey(hiddenColor)) {
                colorsHidden.put(hiddenColor, colorsHidden.get(hiddenColor) + 1);
            } else {
                colorsHidden.put(hiddenColor, 1);
            }
        }

        sc.close();

        Set<Integer> keysShown = colorsShown.keySet();
        Iterator<Integer> iterator = keysShown.iterator();

        int min = 100000;

        while (iterator.hasNext()) {
            int key = iterator.next();
            int shown = colorsShown.get(key);

            if (shown >= a){
                System.out.println(0);
                return;
            }

            if (colorsHidden.get(key) == null) continue;

            int hidden = colorsHidden.get(key);

            if (shown + hidden >= a && a-shown < min){
                min = a-shown;
            }
        }

        if (min != 100000){
            System.out.println(min);
            return;
        }

        Set<Integer> keysHidden = colorsHidden.keySet();
        iterator = keysHidden.iterator();

        while (iterator.hasNext()) {
            int key = iterator.next();
            if (colorsHidden.get(key) >= a){
                System.out.println(a);
                return;
            }
        }
        System.out.println(-1);

    }

}


import java.util.TreeMap;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;

public class Project {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int a = (int)(Math.ceil((float)n / 2.0));

        TreeMap<Integer, Integer> colorsShown = new TreeMap<Integer, Integer>();
        TreeMap<Integer, Integer> colorsHidden = new TreeMap<Integer, Integer>();

        for (int i = 0; i < n; i++) {
            int shownColor = sc.nextInt();
            int hiddenColor = sc.nextInt();

            Integer val = colorsShown.get(shownColor);

            if (val != null) {
                colorsShown.put(shownColor, val + 1);
            } else {
                colorsShown.put(shownColor, 1);
            }

            if (shownColor == hiddenColor) continue;

            val = colorsHidden.get(hiddenColor);

            if (val != null) {
                colorsHidden.put(hiddenColor, val + 1);
            } else {
                colorsHidden.put(hiddenColor, 1);
            }
        }

        sc.close();

        Set<Integer> keysShown = colorsShown.keySet();
        Iterator<Integer> iterator = keysShown.iterator();

        int min = 100000;

        while (iterator.hasNext()) {
            int key = iterator.next();
            int shown = colorsShown.get(key);

            if (shown >= a){
                System.out.println(0);
                return;
            }

            Integer hidden = colorsHidden.get(key);

            if (hidden == null) continue;

            if (shown + hidden >= a && a-shown < min){
                min = a-shown;
            }
        }

        if (min != 100000){
            System.out.println(min);
            return;
        }

        Set<Integer> keysHidden = colorsHidden.keySet();
        iterator = keysHidden.iterator();

        while (iterator.hasNext()) {
            int key = iterator.next();
            if (colorsHidden.get(key) >= a){
                System.out.println(a);
                return;
            }
        }
        System.out.println(-1);

    }

}


import java.util.*;
import java.io.*;
public class a {
  static long mod = 1000000007;
public static void main(String[] args) throws IOException
{
  input.init(System.in);
  PrintWriter out = new PrintWriter(new PrintStream(System.out));
  //input.init(new FileInputStream(new File("input.txt")));
  //PrintWriter out = new PrintWriter(new File("output.txt"));
  HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
  int n = input.nextInt();
  int max = 1;
  int[] as = new int[n], bs = new int[n];
  for(int i = 0; i<n; i++)
  {
    as[i] = input.nextInt(); bs[i] = input.nextInt();
  }
  int[] cs = new int[2*n];
  for(int i = 0; i<n; i++)
  {
    cs[2*i] = as[i];
    cs[2*i+1] = bs[i];
  }
  Arrays.sort(cs);
  boolean okay = false;
  for(int i = 0; i<2*n; i++)
    okay |= i+(n-1)/2 < 2*n && cs[i+(n-1)/2] == cs[i];
  if(!okay) out.println(-1);
  else
  {
    for(int i = 0; i<n; i++)
    {
      if(as[i] != bs[i])
      {
        if(!map.containsKey(as[i])) map.put(as[i], 1);
        else
          {
          int x = map.get(as[i])+1;
          max = Math.max(max, x);
          map.put(as[i], x);
          }
      }
      if(!map.containsKey(bs[i])) map.put(bs[i], 1);
      else
      {
        int x = map.get(bs[i])+1;
        max = Math.max(max, x);
        map.put(bs[i], x);
      }
      if((max + n-i-1)*2 <n) break;
    }
    int min = 987654321;
    if(max*2 >= n)
    for(int x: map.keySet())
    {
      if(map.get(x)*2 < n) continue;
      int count = 0;
      for(int i = 0; i<n; i++) if(as[i] == x) count++;
      min = Math.min(Math.max(0,(n+1)/2 - count), min);
    }
    out.println(min == 987654321 ? -1 : min);
  }

  out.close();
}
static long[][] comb(int n)
{
  long[][] res = new long[n+1][n+1];
  Arrays.fill(res[0], 0);
  for(int i = 0; i<=n; i++) res[i][0] = 1;
  for(int i = 1; i<=n; i++)
    for(int j = 1; j<=n; j++)
      res[i][j] = (res[i-1][j-1] + res[i-1][j])%mod;
  return res;
}
static long gcd(long a, long b)
{
  if(b==0) return a;
  return gcd(b, a%b);
}
static long pow(long a, long p)
{
  if(p<=0) return 1;
  if((p&1) == 0)
  {
    long sqrt = pow(a, p/2);
    return (sqrt*sqrt)%mod;
  }
  else
    return (a*pow(a,p-1))%mod;
}
static class input {
  static BufferedReader reader;
  static StringTokenizer tokenizer;

  /** call this method to initialize reader for InputStream */
  static void init(InputStream input) {
      reader = new BufferedReader(
                   new InputStreamReader(input) );
      tokenizer = new StringTokenizer("");
  }

  /**
   * @return
   */
  public static boolean hasNext() {
    // TODO(mkirsche): Auto-generated method stub
    return tokenizer.hasMoreTokens();
  }

  /** get next word */
  static String next() throws IOException {
      while ( ! tokenizer.hasMoreTokens() ) {
          //TODO add check for eof if necessary
          tokenizer = new StringTokenizer(
                 reader.readLine() );
      }
      return tokenizer.nextToken();
  }

  static int nextInt() throws IOException {
      return Integer.parseInt( next() );
  }
  static long nextLong() throws IOException {
    return Long.parseLong( next() );
}

  static double nextDouble() throws IOException {
      return Double.parseDouble( next() );
  }
  static String nextLine() throws IOException {
    return reader.readLine();
  }
}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;

public class Test {
	static BufferedReader reader;
	static StringTokenizer tokenizer;
	static PrintWriter writer;

	static int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	static long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	static double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	static String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	public static void main(String[] args) throws IOException {
		reader = new BufferedReader(new InputStreamReader(System.in));
		tokenizer = null;
		writer = new PrintWriter(System.out);
		solve();
		reader.close();
		writer.close();
	}

	private static void solve() throws IOException {
		Map<Integer, Integer> up = new HashMap<Integer, Integer>();
		Map<Integer, Integer> down = new HashMap<Integer, Integer>();
		Set<Integer> colors = new HashSet<Integer>();
		int n = nextInt();
		for (int i = 0; i < n; i++) {
			int c1 = nextInt();
			int c2 = nextInt();
			colors.add(c1);
			if (up.containsKey(c1)) {
				up.put(c1, up.get(c1) + 1);
			} else {
				up.put(c1, 1);
			}
			if (c2 != c1) {
				colors.add(c2);
				if (down.containsKey(c2)) {
					down.put(c2, down.get(c2) + 1);
				} else {
					down.put(c2, 1);
				}
			}
		}
		int res = Integer.MAX_VALUE;
		int need = (n + 1) / 2;
		for (int i : colors) {
			int gotu = 0;
			int gotd = 0;
			if (up.containsKey(i)) {
				gotu = up.get(i);
			}
			if (down.containsKey(i)) {
				gotd = down.get(i);
			}
			if (gotu + gotd >= need) {
				int curr = need - gotu;
				if (curr < 0)
					curr = 0;
				if (curr < res)
					res = curr;
			}
		}
		if (res == Integer.MAX_VALUE) {
			writer.println(-1);
		} else {
			writer.println(res);
		}
	}
}


#include<bits/stdc++.h>
#include<tuple>

#define for0(i,n) for(int i = 0;i < n;i++)
#define for1(i,n) for(ll i = 1;i<=n;i++)
#define for2(i,n) for(ll i = 2;i<=n;i++)
#define fastio cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)
/*
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-8
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
*/
using namespace std;
/*
typedef pair<int,int> ii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<pair<long long, long long> > vll;

ll mod = 1e9+7;

ll nop = 100;
vi primes(nop,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll gcd(ll a,ll b){
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}

void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}

ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans *num)%mod;
        }
        num *= num;
        num %= mod;
        e>>=1;
    }
    return ans;
}

ll modinv(ll a){
    return bexp(a,mod-2);
}

bool comp(pair<double,double> x,pair<double,double> y){
    if(x.S == y.S) return x.F <= y.F;
    else return x.S <= y.S;
}
*/
int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t;
    cin>>t;
    while(t--){
        long long n;
        cin>>n;
        n<<=1;
        int dv3 = 1;
        for(int i = 2;i*i <= n;i++){
            if(n%(i*(i+1)) == 0) dv3 = i;
        }
        n /= (dv3*(dv3+1));
        int dv1 = 1;
        for(int i = 2;i*i <= n;i++){
            if(n%i == 0) dv1 = i;
        }
        for0(i,dv1){
            cout<<'1';
        }
        for0(i,dv3+1){
            cout<<'3';
        }
        dv1 = n/dv1;
        for0(i,dv1){
            cout<<'7';
        }
        cout<<endl;
    }
    /* #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif */
    return 0;
}


#include<bits/stdc++.h>
#include<tuple>

#define for0(i,n) for(int i = 0;i < n;i++)
#define for1(i,n) for(ll i = 1;i<=n;i++)
#define for2(i,n) for(ll i = 2;i<=n;i++)
#define fastio cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)
/*
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-8
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
*/
using namespace std;
/*
typedef pair<int,int> ii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<pair<long long, long long> > vll;

ll mod = 1e9+7;

ll nop = 100;
vi primes(nop,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll gcd(ll a,ll b){
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}

void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}

ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans *num)%mod;
        }
        num *= num;
        num %= mod;
        e>>=1;
    }
    return ans;
}

ll modinv(ll a){
    return bexp(a,mod-2);
}

bool comp(pair<double,double> x,pair<double,double> y){
    if(x.S == y.S) return x.F <= y.F;
    else return x.S <= y.S;
}
*/
int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t;
    cin>>t;
    while(t--){
        long long n;
        cin>>n;
        int dv1 = 1;
        for(int i = 2;i*i <= n;i++){
            if(n%i == 0) dv1 = i;
        }
        for0(i,dv1){
            cout<<'1';
        }
        cout<<"33";
        dv1 = n/dv1;
        for0(i,dv1){
            cout<<'7';
        }
        cout<<endl;
    }
    /* #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif */
    return 0;
}


#include<bits/stdc++.h>
#include<tuple>

#define for0(i,n) for(ll i = 0;i < n;i++)
#define for1(i,n) for(ll i = 1;i<=n;i++)
#define for2(i,n) for(ll i = 2;i<=n;i++)
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define fastio cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)
#define F first
#define S second
#define EPS 1e-8
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()

using namespace std;

typedef pair<int,int> ii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<pair<long long, long long> > vll;

ll mod = 1e9+7;

ll nop = 100;
vi primes(nop,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll gcd(ll a,ll b){
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}

void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}

ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans *num)%mod;
        }
        num *= num;
        num %= mod;
        e>>=1;
    }
    return ans;
}

ll modinv(ll a){
    return bexp(a,mod-2);
}

bool comp(pair<double,double> x,pair<double,double> y){
    if(x.S == y.S) return x.F <= y.F;
    else return x.S <= y.S;
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        ll dv = 1;
        for(ll i = 2;i*i <= n;i++){
            if(n%i == 0) dv = i;
        }
        string ans = "";
        for0(i,dv){
            ans += '1';
        }
        ans += "33";
        dv = n/dv;
        for0(i,dv){
            ans += '7';
        }
        cout<<ans<<endl;
    }
    /* #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif */
    return 0;
}


#include<bits/stdc++.h>
#include<tuple>

#define for0(i,n) for(int i = 0;i < n;i++)
#define for1(i,n) for(ll i = 1;i<=n;i++)
#define for2(i,n) for(ll i = 2;i<=n;i++)
#define fastio cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)
/*
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-8
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
*/
using namespace std;
/*
typedef pair<int,int> ii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<pair<long long, long long> > vll;

ll mod = 1e9+7;

ll nop = 100;
vi primes(nop,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll gcd(ll a,ll b){
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}

void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}

ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans *num)%mod;
        }
        num *= num;
        num %= mod;
        e>>=1;
    }
    return ans;
}

ll modinv(ll a){
    return bexp(a,mod-2);
}

bool comp(pair<double,double> x,pair<double,double> y){
    if(x.S == y.S) return x.F <= y.F;
    else return x.S <= y.S;
}
*/
int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t;
    cin>>t;
    while(t--){
        long long n;
        cin>>n;
        n<<=1;
        int dv3 = 1;
        for(int i = 2;i*i <= n;i++){
            if(n%(i*(i+1)) == 0) dv3 = i;
        }
        n /= (dv3*(dv3+1));
        int dv1 = 1;
        for(int i = 2;i*i <= n;i++){
            if(n%i == 0) dv1 = i;
        }
        string ans = "";
        for0(i,dv1){
            ans += '1';
        }
        for0(i,dv3+1){
            ans += '3';
        }
        dv1 = n/dv1;
        for0(i,dv1){
            ans += '7';
        }
        cout<<ans<<endl;
    }
    /* #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif */
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, k) for (int i = 0; i < k; i++)
#define repA(i, a, n) for (int i = a; i <= (n); ++i)
#define repD(i, a, n) for (int i = a; i >= (n); --i)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define INF 1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define LLINF 1e14
#define sz(a) int(a.size())
#define ff first
#define ss second

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vp;
typedef vector<vp> vvp;

int main(int argc, char const *argv[])
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int t; cin >> t;
        while(t--){
        	int n; cin >> n;
        	rep(i, 31){
        		if((n >> i) & 1) cout << "1337";
        		else cout << "1";
        	}
        	cout << '\n';
        }
		return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, k) for (int i = 0; i < k; i++)
#define repA(i, a, n) for (int i = a; i <= (n); ++i)
#define repD(i, a, n) for (int i = a; i >= (n); --i)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define INF 1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define LLINF 1e14
#define sz(a) int(a.size())
#define ff first
#define ss second

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vp;
typedef vector<vp> vvp;

int main(int argc, char const *argv[])
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int t;
        cin >> t;
        while(t--){
        	ll n; cin >> n;
        	vi track;
	        track.pb(0);
	        cout << "1";
	        repD(i, 1e5, 2){
	        	if(i * 1LL * (i - 1) / 2 <= n){
	        		track.pb(i);
	        		n -= (i * 1LL * (i - 1) / 2);
	        	}
	        }
	        sort(all(track));
	        repA(i, 1, sz(track) - 1){
	        	rep(j, track[i] - track[i - 1]) cout << '3'; cout << '7';
	        }
	        cout << '\n';
        }

		return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, k) for (int i = 0; i < k; i++)
#define repA(i, a, n) for (int i = a; i <= (n); ++i)
#define repD(i, a, n) for (int i = a; i >= (n); --i)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define INF 1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define LLINF 1e14
#define sz(a) int(a.size())
#define ff first
#define ss second

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vp;
typedef vector<vp> vvp;

int main(int argc, char const *argv[])
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int t; cin >> t;
        while(t--){
        	int n; cin >> n;
        	rep(i, 31){
        		if((n >> i) & 1) cout << "133";
        		else cout << "1";
        	}
        	cout << "7\n";
        }
		return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, k) for (int i = 0; i < k; i++)
#define repA(i, a, n) for (int i = a; i <= (n); ++i)
#define repD(i, a, n) for (int i = a; i >= (n); --i)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define INF 1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define LLINF 1e14
#define sz(a) int(a.size())
#define ff first
#define ss second

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vp;
typedef vector<vp> vvp;

int main(int argc, char const *argv[])
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int t;
        cin >> t;
        while(t--){
        	ll n; cin >> n;
	        cout << "1";
	        repD(i, 1e5, 1){
	        	if(i * 1LL * (i - 1) / 2 <= n){
	        		rep(j, i) cout << '3'; cout << '7';
	        		n -= (i * 1LL * (i - 1) / 2);
	        	}
	        }
	        cout << '\n';
        }

		return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, k) for (int i = 0; i < k; i++)
#define repA(i, a, n) for (int i = a; i <= (n); ++i)
#define repD(i, a, n) for (int i = a; i >= (n); --i)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define INF 1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define LLINF 1e14
#define sz(a) int(a.size())
#define ff first
#define ss second

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vp;
typedef vector<vp> vvp;

int main(int argc, char const *argv[])
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int t;
        cin >> t;
        while(t--){
        	ll n; cin >> n;
	        cout << "1";
	        repD(i, 1e5, 2){
	        	if(i * 1LL * (i - 1) / 2 <= n){
	        		rep(j, i) cout << '3'; cout << '7';
	        		n -= (i * 1LL * (i - 1) / 2);
	        	}
	        }
	        cout << '\n';
        }

		return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, k) for (int i = 0; i < k; i++)
#define repA(i, a, n) for (int i = a; i <= (n); ++i)
#define repD(i, a, n) for (int i = a; i >= (n); --i)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define INF 1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define LLINF 1e14
#define sz(a) int(a.size())
#define ff first
#define ss second

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vp;
typedef vector<vp> vvp;

int main(int argc, char const *argv[])
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int t;
        cin >> t;
        while(t--){
        	ll n; cin >> n;
        	int x = 0;
        	for(; ; x++){
        		if(x * 1LL * (x - 1) / 2 > n) break;
        	}
        	x--;
        	cout << 133;
        	int rem = n - x * (x - 1) / 2;
        	rep(i, rem) cout << 7;
        	rep(i, x - 2) cout << 3; cout << 7 << '\n';
        }

		return 0;
}


#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
#define ll long long int
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define rep(i,l,r) for(i=l;i<r;i++)
#define bep(i,l,r) for(i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
int main()
{
    io;
    int t;
    cin>>t;
    int i,j;
    rep(i,0,t)
    {
        int n,n1;
        cin>>n;
        string s;
        int num=2*n;
        n1=(int)sqrt(num);
        num=num-n1*(n1-1);
        s+='1';
        rep(j,0,2)
        s+='3';
        rep(j,0,num/2)
        s+='7';
        rep(j,0,n1-2)
        s+='3';
        s+='7';
        cout<<s<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
#define ll long long int
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define rep(i,l,r) for(i=l;i<r;i++)
#define bep(i,l,r) for(i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
int main()
{
    io;
    int t;
    cin>>t;
    int i,j;
    rep(i,0,t)
    {
        int n,n1;
        cin>>n;
        string s;
        int num=2*n;
        while(num>3)
        {
        n1=(int)sqrt(num);
        num=num-n1*(n1-1);
        s+='1';
        rep(j,0,n1)
        s+='3';
        s+='7';
        }
        rep(j,0,num/2)
        s+='1';
        s+="337";
        cout<<s<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
#define ll long long int
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define rep(i,l,r) for(i=l;i<r;i++)
#define bep(i,l,r) for(i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
int main()
{
    int i,j,k,t;
    cin>>t;
    ll n;
    rep(i,0,t)
    {
        cin>>n;
        ll num=n;
        vector<ll>v;
        string s;
        while(num)
        {
        ll j=1;
        while(j*j<num)
        {
            j++;
        }
        if(j*j>num)
            j--;
        num=num-j*j;
        v.pb(j);
        }
        rep(j,0,v.size())
        {
            rep(k,0,v[j])
            s+="1";
            s+="33";
            rep(k,0,v[j])
            s+="7";
        }
        cout<<s<<"\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
#define ll long long int
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define rep(i,l,r) for(i=l;i<r;i++)
#define bep(i,l,r) for(i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
int main()
{
    io;
    int t;
    cin>>t;
    int i,j;
    rep(i,0,t)
    {
        int n,n1;
        cin>>n;
        string s;
        int num=2*n;
        n1=(int)sqrt(num);
        num=num-n1*(n1-1);
        s+='1';
        rep(j,0,2)
        s+='3';
        rep(j,0,num/2)
        s+='7';
        if(n1>2)
        {
        rep(j,0,n1-2)
        s+='3';
        s+='7';
        }
        cout<<s<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
#define ll long long int
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define rep(i,l,r) for(i=l;i<r;i++)
#define bep(i,l,r) for(i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
int main()
{
    int i,j,k,t;
    cin>>t;
    ll n;
    rep(i,0,t)
    {
        cin>>n;
        ll num=n;
        vector<ll>v;
        string s;
        while(num)
        {
        ll j=1;
        while(j*j<num)
        {
            j++;
        }
        if(j*j>num)
            j--;
        num=j*j-num;
        v.pb(j);
        }
        rep(j,0,v.size())
        {
            rep(k,0,v[j])
            s+="1";
            s+="33";
            rep(k,0,v[j])
            s+="1";
            s+="7";
        }
        cout<<s<<"\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
#define ll long long int
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define rep(i,l,r) for(i=l;i<r;i++)
#define bep(i,l,r) for(i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
int main()
{
    io;
    int t;
    cin>>t;
    int i,j;
    rep(i,0,t)
    {
        int n,n1;
        cin>>n;
        string s;
        int num=2*n;
        n1=(int)sqrt(num);
        num=num-n1*(n1-1);
        s+='1';
        rep(j,0,2)
        s+='3';
        rep(j,0,num/2)
        s+='7';
        if(n1>=2)
        {
        rep(j,0,n1-2)
        s+='3';
        s+='7';
        }
        cout<<s<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
#define ll long long int
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define rep(i,l,r) for(i=l;i<r;i++)
#define bep(i,l,r) for(i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
int main()
{
    io;
    int t;
    cin>>t;
    int i,j,k;
    rep(i,0,t)
    {
        int n,num;
        cin>>n;
        string s;
        if(n==1)
        {
            cout<<"1337\n";
            continue;
        }
        j=2;
        num=n;
        while((j*(j-1))/2<=n)
            j++;
        j=j-1;
        num=num-(j*(j-1))/2;
        s+='1';
        rep(k,0,2)
        s+='3';
        rep(k,0,num)
        s+='7';
        rep(k,0,j-2)
        s+='3';
        s+='7';
        cout<<s<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
const int INF = 1e9;

int main() {
    int t;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        bool ok = false;
        for (int x = 1; x < int(1e5) + 1; x++) {
            int q = n % x;
            int newn = n - (5 * x + 1) * q;
            int y;
            if (newn % x == 0) y = newn / x;
            else continue;
            if (x + 5 + y + q <= int(1e5)) {
                    ok = true;
                    //cout << x + 5 +y + q << endl;
                for (int i = 0; i < x; i++) cout << 1;
                cout << 33;
                for (int i = 0; i < y; i++) cout << 7;
                cout << 133;
                for (int i = 0; i < q; i++) cout << 7;
                cout << endl;
                break;
            }
        }
        assert(ok);
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
const int INF = 1e9;

int main() {
    int t;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        bool ok = false;
        for (int x = 1; x < int(1e5) + 1; x++) {
            int q = n % x;
            int newn = n - (4 * x + 1) * q;
            int y;
            if (newn % x == 0) y = newn / x;
            else continue;
            if (x + 5 + y + q <= int(1e5)) {
                    ok = true;
                    cout << x + 5 +y + q << endl;
                for (int i = 0; i < x; i++) cout << 1;
                cout << 33;
                for (int i = 0; i < y; i++) cout << 7;
                cout << 133;
                for (int i = 0; i < q; i++) cout << 7;
                cout << endl;
                break;
            }
        }
        assert(ok);
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
const int INF = 1e9;

int main() {
    int t;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        long long sum = INF;
        int dividor = 0;
        for (long long i = 1; i * i <= n; i++) {
            //cout << i << endl;
            if (n % i == 0) {
                if (sum > n / i + i) {
                    sum = n / i + i;
                    dividor = i;
                }
            }
        }
        cout << sum << endl;
        for (int i = 0; i < dividor; i++) cout << 1;
        cout << 33;
        for (int i = 0; i < sum - dividor; i++) cout << 7;
        cout << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
const int INF = 1e9;

int main() {
    int t;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        bool ok = false;
        for (int x = 1; x < int(1e5) + 1; x++) {
            int q = n % x;
            int newn = n - (4 * x + 1) * q;
            int y;
            if (newn % x == 0) y = newn / x;
            else continue;
            if (x + 5 + y + q <= int(1e5)) {
                    ok = true;
                    //cout << x + 5 +y + q << endl;
                for (int i = 0; i < x; i++) cout << 1;
                cout << 33;
                for (int i = 0; i < y; i++) cout << 7;
                cout << 133;
                for (int i = 0; i < q; i++) cout << 7;
                cout << endl;
                break;
            }
        }
        assert(ok);
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
const int INF = 1e9;

int main() {
    int t;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        bool ok = false;
        for (int x = 1; x < int(1e5) + 1; x++) {
            int q = n % x;
            int newn = n - (6 * x + 1) * q;
            int y;
            if (newn % x == 0) y = newn / x;
            else continue;
            if (x + 5 + y + q <= int(1e5)) {
                    ok = true;
                    //cout << x + 5 +y + q << endl;
                for (int i = 0; i < x; i++) cout << 1;
                cout << 33;
                for (int i = 0; i < y; i++) cout << 7;
                cout << 133;
                for (int i = 0; i < q; i++) cout << 7;
                cout << endl;
                break;
            }
        }
        assert(ok);
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
const int INF = 1e9;

int main() {
    int t;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        long long sum = INF;
        int dividor = 0;
        for (long long i = 1; i * i <= n; i++) {
            //cout << i << endl;
            if (n % i == 0) {
                if (sum > n / i + i) {
                    sum = n / i + i;
                    dividor = i;
                }
            }
        }
        //cout << sum << endl;
        for (int i = 0; i < dividor; i++) cout << 1;
        cout << 33;
        for (int i = 0; i < sum - dividor; i++) cout << 7;
        cout << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define lp(i, x, y) for(int i = x ; i < y ; i++)
#define lp_rev(i, x, y) for(int i = x ; i >= y ; i--)
#define ff first
#define ss second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(v)  v.begin(), v.end()
#define vll vector<long long int>
#define vi vector<int>
#define Fasttt ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
typedef unsigned long long ull;
typedef long long ll;
#define endl "\n"
ll mod = 1000000007;

int main()
{
	Fasttt;
	int tst;
	cin>> tst;
	while(tst--)
	{
		int n;
		cin>> n;
		int x = -1, y = -1, st = sqrt(n);
		for(int i = st; i >= 0; i--)
		{
			if(n%i == 0)
			{
				x = i;
				y = n/x;
				break;
			}
		}
		if(x == -1)
		{
			lp(i, 0, n)
				cout<< 1;
			cout<< 337<< endl;
			continue;
		}
		lp(i, 0, x)
			cout<< 1;
		cout<< 33;
		lp(i, 0, y)
			cout<< 7;
		cout<< endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define lp(i, x, y) for(int i = x ; i < y ; i++)
#define lp_rev(i, x, y) for(int i = x ; i >= y ; i--)
#define ff first
#define ss second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(v)  v.begin(), v.end()
#define vll vector<long long int>
#define vi vector<int>
#define Fasttt ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
typedef unsigned long long ull;
typedef long long ll;
#define endl "\n"
ll mod = 1000000007;

int main()
{
	Fasttt;
	int tst;
	cin>> tst;
	string s;
	lp(i, 0, 100000)
		s.pb('1');
	while(tst--)
	{
		int n;
		cin>> n;
		while(n > 100000)
		{
			cout<< s;
			n = n - 10000;
		}
		lp(i, 0, n)
			cout<< 1;
		cout<< 337<< endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define lp(i, x, y) for(int i = x ; i < y ; i++)
#define lp_rev(i, x, y) for(int i = x ; i >= y ; i--)
#define ff first
#define ss second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(v)  v.begin(), v.end()
#define vll vector<long long int>
#define vi vector<int>
#define Fasttt ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
typedef unsigned long long ull;
typedef long long ll;
#define endl "\n"
ll mod = 1000000007;

int main()
{
	Fasttt;
	int tst;
	cin>> tst;
	while(tst--)
	{
		int n;
		cin>> n;
		lp(i, 0, n)
			cout<< 1;
		cout<< 337<< endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define lp(i, x, y) for(int i = x ; i < y ; i++)
#define lp_rev(i, x, y) for(int i = x ; i >= y ; i--)
#define ff first
#define ss second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(v)  v.begin(), v.end()
#define vll vector<long long int>
#define vi vector<int>
#define Fasttt ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
typedef unsigned long long ull;
typedef long long ll;
#define endl "\n"
ll mod = 1000000007;

int main()
{
	Fasttt;
	int tst;
	cin>> tst;
	string s;
	lp(i, 0, 10000)
		s.pb('1');
	while(tst--)
	{
		int n;
		cin>> n;
		while(n > 10000)
		{
			cout<< s;
			n = n - 10000;
		}
		lp(i, 0, n)
			cout<< 1;
		cout<< 337<< endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (int i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL)
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
	int n;
	cin>> n;
	int val = 2;
	while(true){
		if(val * (val - 1) / 2  >  n)
			break;
		val++;
	}
	val--;
	n -= (val * (val - 1) / 2);
	cout<< "133";
	rep(i, 0, n)
		cout<< "7";
	val -= 2;
	rep(i, 0, val)
		cout<< "3";
	cout<< "7\n";
	return 0;
}

int main()
{
    fast;
    int t = 1;
    cin>> t;
    while(t--){
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);

/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/

//lower bound   >=
//upper bound   >


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    // freopen("out.txt","w",stdout);
    int T;scanf("%d",&T);while(T--)
    {
        long long n;scanf("%lld",&n);
        if(n<=1e5-3)
        {
            printf("133");
            for(int i=1;i<=n;i++) printf("7");
            puts("");
            continue;
        }
        long long t=2;
        while(true)
        {
            long long now=t*(t-1)/2;
            if(now>n)
            {
                t-=1;
                break;
            }
            t+=1;
        }
        long long r=n-(t*(t-1)/2);
        if(r<=1){t-=1;r=n-(t*(t-1)/2);}
        printf("1");printf("33");
        for(long long i=1;i<=r-1;i++) printf("7");
        for(long long i=1;i<=t;i++) printf("3");
        printf("7\n");
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    // freopen("out.txt","w",stdout);
    int T;scanf("%d",&T);while(T--)
    {
        long long n;scanf("%lld",&n);
        long long t=2;
        while(true)
        {
            long long now=t*(t-1)/2;
            if(now>n)
            {
                t-=1;
                break;
            }
            t+=1;
        }
        long long r=n-(t*(t-1)/2);
        if(r<=1){t-=1;r=n-(t*(t-1)/2);}
        printf("1");printf("33");
        for(long long i=1;i<=r-1;i++) printf("7");
        for(long long i=1;i<=t;i++) printf("3");
        printf("7\n");
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    // freopen("out.txt","w",stdout);
    int T;scanf("%d",&T);while(T--)
    {
        long long n;scanf("%lld",&n);
        if(n<=1e5-3)
        {
            printf("133");
            for(int i=1;i<=n;i++) printf("7");
            puts("");
            continue;
        }
        long long t=2;
        while(true)
        {
            long long now=t*(t-1)/2;
            if(now>n)
            {
                t-=1;
                break;
            }
            t+=1;
        }
        long long r=n-(t*(t-1)/2);
        printf("1");printf("33");
        for(long long i=1;i<=r;i++) printf("7");
        for(long long i=1;i<=t-2;i++) printf("3");
        printf("7\n");
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=1e5;
int main()
{
    int T;scanf("%d",&T);while(T--)
    {
        long long n;scanf("%lld",&n);
        int three;
        long long now;
        for(three=maxn;three>=2;three--)
        {
            now=(long long )three*(three-1)/2;
            if(now>n) continue;
            if(n%now==0) break;
        }
        int last=n/now;
        int i;for(i=1;i<=last;i++)
        {
            if(last%i) continue;
            if(last/i+i+three<=maxn) break;
        }
        for(int x=1;x<=i;x++) printf("1");
        for(int x=1;x<=three;x++) printf("3");
        for(int x=1;x<=last/i;x++) printf("7");
        puts("");
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=1e5;
int main()
{
    int T;scanf("%d",&T);while(T--)
    {
        long long n;scanf("%lld",&n);
        long long t=2;
        while(true)
        {
            long long now=t*(t-1)/2;
            if(now>n)
            {
                t-=1;
                break;
            }
            t+=1;
        }
        long long r=n-(t*(t-1)/2);
        printf("1");
        for(int i=1;i<=t;i++) printf("3");
        printf("7");
        if(r) printf("33");
        for(int i=1;i<=r;i++) printf("7");
        puts("");
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=1e5;
int main()
{
    int T;scanf("%d",&T);while(T--)
    {
        int n;scanf("%d",&n);
        int i;for(i=1;i<=n;i++)
        {
            if(n%i) continue;
            if(1+i+(n/i)<=maxn) break;
        }
        for(int x=1;x<=i;x++) printf("1");
        for(int x=1;x<=(n/i);x++) printf("3");
        printf("7\n");
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    // freopen("out.txt","w",stdout);
    int T;scanf("%d",&T);while(T--)
    {
        long long n;scanf("%lld",&n);
        if(n<=1e5-3)
        {
            printf("133");
            for(int i=1;i<=n;i++) printf("7");
            puts("");
        }
        long long t=2;
        while(true)
        {
            long long now=t*(t-1)/2;
            if(now>n)
            {
                t-=1;
                break;
            }
            t+=1;
        }
        long long r=n-(t*(t-1)/2);
        if(r<=1){t-=1;r=n-(t*(t-1)/2);}
        printf("1");printf("33");
        for(long long i=1;i<=r-1;i++) printf("7");
        for(long long i=1;i<=t;i++) printf("3");
        printf("7\n");
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=1e5;
int main()
{
    int T;scanf("%d",&T);while(T--)
    {
        long long n;scanf("%lld",&n);
        long long t=2;
        while(true)
        {
            long long now=t*(t-1)/2;
            if(now>n)
            {
                t-=1;
                break;
            }
            t+=1;
        }
        long long r=n-(t*(t-1)/2);
        printf("1");
        if(r) printf("33");
        for(long long i=1;i<=r;i++) printf("7");
        for(long long i=1;i<=t;i++) printf("3");
        printf("7");
        puts("");
    }
    return 0;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
//#include <unordered_map>
#include <numeric>

using namespace std;

const int mod = 1e9 + 7;

const int N = 3e5;
long long n, m;
int a[N];
int main() {

	int t;
	scanf("%d", &t);
	while(t--) {
	     scanf("%lld", &n);
	for(long long i = 50000; i >=2; i--)
	if(n >= ((i - 1) * 1LL * i / 2) && n - (i - 1) * 1LL * i / 2 + i + 2 <= 100000){
	    n -= (i - 1) * 1LL * i / 2;

	    printf("1");
	    long long z = i;
	    while(z > 2){ z--;printf("3");}
	    while(n--) printf("1");
	    while(z--) printf("3");
	    printf("7\n");
	    break;
	}else if(n >= ((i - 1) * 1LL * i / 2) && (n - (i - 1) * 1LL * i / 2) % 2 == 0) {
	    if((n - (i - 1) * 1LL * i / 2) + i + 2 <= 100000) {
	        n -= (i - 1) * 1LL * i / 2;;
	        for(long long x = 1; x <= n / 2; x++) printf("1");
	        long long z = i;
	    while(z--) printf("3");
	    while(n--)printf("7");
	    }
	}

	}
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
//#include <unordered_map>
#include <numeric>

using namespace std;

const int mod = 1e9 + 7;

const int N = 3e5;
long long n, m;
int a[N];
int main() {
	ios_base::sync_with_stdio(0);
	int t;
	cin >> t;
	while(t--) {
	     cin >> n;
	for(int i = 35000; i >=2; i--)
	if(n >= ((i - 1) * 1LL * i / 2) ){
	    n -= (i - 1) * 1LL * i / 2;
	    string s = "";
	    while(n--) s += "1";
	    s += "1";
	    long long z = i;
	    while(z --) s += "3";
	    s += "7";
	    cout << s << endl;
	}

	}
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
//#include <unordered_map>
#include <numeric>

using namespace std;

const int mod = 1e9 + 7;

const int N = 3e5;
long long n, m;
int a[N];
int main() {

	int t;
	scanf("%d", &t);
	while(t--) {
	     scanf("%lld", &n);
	for(long long i = 50000; i >=2; i--)
	if(n >= ((i - 1) * 1LL * i / 2) && n - (i - 1) * 1LL * i / 2 + i + 2 <= 100000){
	    n -= (i - 1) * 1LL * i / 2;

	    printf("1");
	    long long z = i;
	    while(z -- > 3) printf("3");
	    while(n--) printf("1");
	    while(z--) printf("3");
	    printf("7\n");
	    break;
	}else if(n >= ((i - 1) * 1LL * i / 2) && (n - (i - 1) * 1LL * i / 2) % 2 == 0) {
	    if((n - (i - 1) * 1LL * i / 2) + i + 2 <= 100000) {
	        n -= (i - 1) * 1LL * i / 2;;
	        for(long long x = 1; x <= n / 2; x++) printf("1");
	        long long z = i;
	    while(z--) printf("3");
	    while(n--)printf("7");
	    }
	}

	}
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
//#include <unordered_map>
#include <numeric>

using namespace std;

const int mod = 1e9 + 7;

const int N = 3e5;
long long n, m;
int a[N];
int main() {

	int t;
	scanf("%d", &t);
	while(t--) {
	     scanf("%lld", &n);
	for(int i = 100000; i >=2; i--)
	if(n >= ((i - 1) * 1LL * i / 2) ){
	    n -= (i - 1) * 1LL * i / 2;

	    while(n--) printf("1");
	    printf("1");
	    long long z = i;
	    while(z --) printf("3");

	    printf("7\n");
	    break;
	}

	}
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
//#include <unordered_map>
#include <numeric>

using namespace std;

const int mod = 1e9 + 7;

const int N = 3e5;
long long n, m;
int a[N];
int main() {

	int t;
	scanf("%d", &t);
	while(t--) {
	     scanf("%lld", &n);
	for(long long i = 50000; i >=2; i--)
	if(n >= ((i - 1) * 1LL * i / 2) && n - (i - 1) * 1LL * i / 2 + i + 2 <= 100000){
	    n -= (i - 1) * 1LL * i / 2;

	    while(n--) printf("1");
	    printf("1");
	    long long z = i;
	    while(z --) printf("3");

	    printf("7\n");
	    break;
	}else if(n >= ((i - 1) * 1LL * i / 2) && (n - (i - 1) * 1LL * i / 2) % 2 == 0) {
	    if((n - (i - 1) * 1LL * i / 2) + i + 2 <= 100000) {
	        n -= (i - 1) * 1LL * i / 2;;
	        for(long long x = 1; x <= n / 2; x++) printf("1");
	        long long z = i;
	    while(z--) printf("3");
	    while(n--)printf("7");
	    }
	}

	}
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
//#include <unordered_map>
#include <numeric>

using namespace std;

const int mod = 1e9 + 7;

const int N = 3e5;
long long n, m;
int a[N];
int main() {
	ios_base::sync_with_stdio(0);
	int t;
	cin >> t;
	while(t--) {
	     cin >> n;
	for(int i = 35000; i >=2; i--)
	if(n >= ((i - 1) * 1LL * i / 2) ){
	    n -= (i - 1) * 1LL * i / 2;

	    while(n--) cout<<1;
	    cout<<1;
	    long long z = i;
	    while(z --) cout<<3;

	    cout << 7 << endl;
	    break;
	}

	}
}


#include <bits/stdc++.h>
using namespace std;

int t, n;

int main()
{
    scanf("%d", &t);
    while (t--) {
        scanf("%d", &n);
        if (n <= 100000 - 3) {
            for (int i = 1; i <= n; ++i) printf("1");
            printf("337\n");
            continue;
        }
        for (int i = 2; i <= sqrt(n) + 1; ++i) {
            if (n % i == 0) {
                for (int k = 1; k <= i; ++k) printf("1");
                printf("33");
                for (int k = 1; k <= n / i; ++k) printf("7");
                puts("");
                break;
            }
        }
    }
    return 0;
}


#include <cstdio>

long long t, n, num3, num7;

int main()
{
    scanf("%lld", &t);
    while (t--) {
        scanf("%lld", &n);
        num3 = num7 = 1;
        while (n >= (num3 - 1) * num3 / 2) { ++num3; }
        --num3;
        long long tmp = num3 * (num3 - 1) / 2;
        while (n >= num7 * tmp) { ++num7; }
        --num7;
        n -= num7 * tmp;
        printf("133");
        for (int i = 1; i <= n; ++i) printf("7");
        for (int i = 1; i <= num3 - 2; ++i) printf("3");
        for (int i = 1; i <= num7; ++i) printf("7");
        puts("");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct ioss {
#define endl '\n'
	static const int LEN = 500000;
	char obuf[LEN], *oh = obuf;
	bool eof=false;
	inline char gc() {

		static char buf[LEN], *s, *t, buf2[LEN];
		return (s == t) && (t = (s = buf) + fread(buf, 1, LEN, stdin)), s == t ? -1 : *s++;
	}
	inline ioss & operator >> (long long&x) {
		static char ch, sgn, *p;
		ch = gc(), sgn = 0;
		for (; !isdigit(ch); ch = gc()) { if (ch == -1)return *this; sgn |= ch == '-'; }
		for (x = 0; isdigit(ch); ch = gc())x = x * 10 + (ch^'0');
		sgn && (x = -x); return *this;
	}
	inline ioss & operator >> (int &x) {
		static char ch, sgn, *p;
		ch = gc(), sgn = 0;
		for (; !isdigit(ch); ch = gc())
		{
			if (ch == -1)
			{
				eof = true;
				return *this;
			}
			sgn |= ch == '-'; }
		for (x = 0; isdigit(ch); ch = gc())x = x * 10 + (ch^'0');
		sgn && (x = -x); return *this;
	}
	inline ioss & operator >> (char&x)
	{
		static char ch;
		for (; !isalpha(ch) && !isdigit(ch); ch = gc())
			if (ch == -1)return *this;
		for (; isalpha(ch) || isdigit(ch); ch = gc())
			x = ch;
		return *this;
	}
	inline ioss & operator >> (string &x)
	{
		static char ch, *p, buf2[LEN];
		for (; !isalpha(ch) && !isdigit(ch); ch = gc())
			if (ch == -1)
			{
				eof = true;
				return *this;
			}
		p = buf2;
		for (; isalpha(ch) || isdigit(ch); ch = gc())
			*p = ch, p++;
		*p = '\0';
		x = buf2;
		return *this;
	}
	inline ioss & operator <<(string &c)
	{
		for (auto &p : c)
			this->operator<<(p);
		return *this;
	}
	inline ioss & operator <<(const char *c)
	{
		while (*c != '\0')
		{
			this->operator<<(*c);
			c++;
		}
		return *this;
	}
	inline ioss & operator <<(const char &c) {
		oh == obuf + LEN ? (fwrite(obuf, 1, LEN, stdout), oh = obuf) : 0;
		*oh++ = c;
		return *this;
	}
	inline ioss & operator <<(int x) {
		static int buf[30], cnt;
		if (x < 0)
			this->operator<<('-'), x = -x;
		if (x == 0)
			this->operator<<('0');
		for (cnt = 0; x; x /= 10) buf[++cnt] = x % 10 | 48;
		while (cnt) this->operator<<((char)buf[cnt--]);
		return *this;
	}
	inline ioss & operator <<(long long x) {
		static int buf[30], cnt;
		if (x < 0)
			this->operator<<('-'), x = -x;
		if (x == 0)
			this->operator<<('0');
		for (cnt = 0; x; x /= 10) buf[++cnt] = x % 10 | 48;
		while (cnt) this->operator<<((char)buf[cnt--]);
		return *this;
	}
	~ioss()
	{
		fwrite(obuf, 1, oh - obuf, stdout);
	}
} io;

int t, n;

int main()
{
    io >> t;
    while (t--) {
        io >> n;
        if (n <= 1000) {
            for (int i = 1; i <= n; ++i)
                io << 1;
            io << 337 << '\n';
            continue;
        }
        bool flag = false;
        int a, b;
        for (int i = 2; i <= sqrt(n) + 1; ++i) {
            if (n % i == 0) {
                a = i;  b = n / i;
                flag = true;
            }
        }
        if (flag) {
            for (int k = 1; k <= a; ++k) io << 1;
            io << 33;
            for (int k = 1; k <= b; ++k) io << 7;
            io << '\n';
        }
        else {
            int tmp = (n - 13) / 2;
            io << 1337;
            for (int i = 1; i <= tmp; ++i) io << 1;
            io << 3377;
            io << '\n';
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct ioss {
#define endl '\n'
	static const int LEN = 500000;
	char obuf[LEN], *oh = obuf;
	bool eof=false;
	inline char gc() {

		static char buf[LEN], *s, *t, buf2[LEN];
		return (s == t) && (t = (s = buf) + fread(buf, 1, LEN, stdin)), s == t ? -1 : *s++;
	}
	inline ioss & operator >> (long long&x) {
		static char ch, sgn, *p;
		ch = gc(), sgn = 0;
		for (; !isdigit(ch); ch = gc()) { if (ch == -1)return *this; sgn |= ch == '-'; }
		for (x = 0; isdigit(ch); ch = gc())x = x * 10 + (ch^'0');
		sgn && (x = -x); return *this;
	}
	inline ioss & operator >> (int &x) {
		static char ch, sgn, *p;
		ch = gc(), sgn = 0;
		for (; !isdigit(ch); ch = gc())
		{
			if (ch == -1)
			{
				eof = true;
				return *this;
			}
			sgn |= ch == '-'; }
		for (x = 0; isdigit(ch); ch = gc())x = x * 10 + (ch^'0');
		sgn && (x = -x); return *this;
	}
	inline ioss & operator >> (char&x)
	{
		static char ch;
		for (; !isalpha(ch) && !isdigit(ch); ch = gc())
			if (ch == -1)return *this;
		for (; isalpha(ch) || isdigit(ch); ch = gc())
			x = ch;
		return *this;
	}
	inline ioss & operator >> (string &x)
	{
		static char ch, *p, buf2[LEN];
		for (; !isalpha(ch) && !isdigit(ch); ch = gc())
			if (ch == -1)
			{
				eof = true;
				return *this;
			}
		p = buf2;
		for (; isalpha(ch) || isdigit(ch); ch = gc())
			*p = ch, p++;
		*p = '\0';
		x = buf2;
		return *this;
	}
	inline ioss & operator <<(string &c)
	{
		for (auto &p : c)
			this->operator<<(p);
		return *this;
	}
	inline ioss & operator <<(const char *c)
	{
		while (*c != '\0')
		{
			this->operator<<(*c);
			c++;
		}
		return *this;
	}
	inline ioss & operator <<(const char &c) {
		oh == obuf + LEN ? (fwrite(obuf, 1, LEN, stdout), oh = obuf) : 0;
		*oh++ = c;
		return *this;
	}
	inline ioss & operator <<(int x) {
		static int buf[30], cnt;
		if (x < 0)
			this->operator<<('-'), x = -x;
		if (x == 0)
			this->operator<<('0');
		for (cnt = 0; x; x /= 10) buf[++cnt] = x % 10 | 48;
		while (cnt) this->operator<<((char)buf[cnt--]);
		return *this;
	}
	inline ioss & operator <<(long long x) {
		static int buf[30], cnt;
		if (x < 0)
			this->operator<<('-'), x = -x;
		if (x == 0)
			this->operator<<('0');
		for (cnt = 0; x; x /= 10) buf[++cnt] = x % 10 | 48;
		while (cnt) this->operator<<((char)buf[cnt--]);
		return *this;
	}
	~ioss()
	{
		fwrite(obuf, 1, oh - obuf, stdout);
	}
} io;

int t, n;

int main()
{
    io >> t;
    while (t--) {
        io >> n;
        if (n <= 1000) {
            for (int i = 1; i <= n; ++i)
                io << 1;
            io << 337 << '\n';
            continue;
        }
        bool flag = false;
        int a, b;
        for (int i = 2; i <= sqrt(n) + 1; ++i) {
            if (n % i == 0) {
                a = i;  b = n / i;
                flag = true;
            }
        }
        if (flag) {
            for (int k = 1; k <= a / 2; ++k) io << 11;
            if (a % 2) io << 1;
            io << 33;
            for (int k = 1; k <= b / 2; ++k) io << 77;
            if (b % 2) io << 7;
            io << '\n';
        }
        else {
            int tmp = (n - 13) / 2;
            io << 1337;
            for (int i = 1; i <= tmp; ++i) io << 1;
            io << 3377;
            io << '\n';
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct ioss {
#define endl '\n'
	static const int LEN = 500000;
	char obuf[LEN], *oh = obuf;
	bool eof=false;
	inline char gc() {

		static char buf[LEN], *s, *t, buf2[LEN];
		return (s == t) && (t = (s = buf) + fread(buf, 1, LEN, stdin)), s == t ? -1 : *s++;
	}
	inline ioss & operator >> (long long&x) {
		static char ch, sgn, *p;
		ch = gc(), sgn = 0;
		for (; !isdigit(ch); ch = gc()) { if (ch == -1)return *this; sgn |= ch == '-'; }
		for (x = 0; isdigit(ch); ch = gc())x = x * 10 + (ch^'0');
		sgn && (x = -x); return *this;
	}
	inline ioss & operator >> (int &x) {
		static char ch, sgn, *p;
		ch = gc(), sgn = 0;
		for (; !isdigit(ch); ch = gc())
		{
			if (ch == -1)
			{
				eof = true;
				return *this;
			}
			sgn |= ch == '-'; }
		for (x = 0; isdigit(ch); ch = gc())x = x * 10 + (ch^'0');
		sgn && (x = -x); return *this;
	}
	inline ioss & operator >> (char&x)
	{
		static char ch;
		for (; !isalpha(ch) && !isdigit(ch); ch = gc())
			if (ch == -1)return *this;
		for (; isalpha(ch) || isdigit(ch); ch = gc())
			x = ch;
		return *this;
	}
	inline ioss & operator >> (string &x)
	{
		static char ch, *p, buf2[LEN];
		for (; !isalpha(ch) && !isdigit(ch); ch = gc())
			if (ch == -1)
			{
				eof = true;
				return *this;
			}
		p = buf2;
		for (; isalpha(ch) || isdigit(ch); ch = gc())
			*p = ch, p++;
		*p = '\0';
		x = buf2;
		return *this;
	}
	inline ioss & operator <<(string &c)
	{
		for (auto &p : c)
			this->operator<<(p);
		return *this;
	}
	inline ioss & operator <<(const char *c)
	{
		while (*c != '\0')
		{
			this->operator<<(*c);
			c++;
		}
		return *this;
	}
	inline ioss & operator <<(const char &c) {
		oh == obuf + LEN ? (fwrite(obuf, 1, LEN, stdout), oh = obuf) : 0;
		*oh++ = c;
		return *this;
	}
	inline ioss & operator <<(int x) {
		static int buf[30], cnt;
		if (x < 0)
			this->operator<<('-'), x = -x;
		if (x == 0)
			this->operator<<('0');
		for (cnt = 0; x; x /= 10) buf[++cnt] = x % 10 | 48;
		while (cnt) this->operator<<((char)buf[cnt--]);
		return *this;
	}
	inline ioss & operator <<(long long x) {
		static int buf[30], cnt;
		if (x < 0)
			this->operator<<('-'), x = -x;
		if (x == 0)
			this->operator<<('0');
		for (cnt = 0; x; x /= 10) buf[++cnt] = x % 10 | 48;
		while (cnt) this->operator<<((char)buf[cnt--]);
		return *this;
	}
	~ioss()
	{
		fwrite(obuf, 1, oh - obuf, stdout);
	}
} io;

int t, n;

int main()
{
    io >> t;
    while (t--) {
        io >> n;
        if (n <= 1000) {
            for (int i = 1; i <= n; ++i)
                io << 1;
            io << 337 << '\n';
            continue;
        }
        bool flag = false;
        for (int i = 2; i <= sqrt(n) + 1; ++i) {
            if (n % i == 0) {
                flag = true;
                for (int k = 1; k <= i; ++k) io << 1;
                io << 33;
                for (int k = 1; k <= n / i; ++k) io << 7;
                io << '\n';
                break;
            }
        }
        if (!flag) {
            int tmp = (n - 13) / 2;
            io << 1337;
            for (int i = 1; i <= tmp; ++i) io << 1;
            io << 3377;
            io << '\n';
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct ioss {
#define endl '\n'
	static const int LEN = 500000;
	char obuf[LEN], *oh = obuf;
	bool eof=false;
	inline char gc() {

		static char buf[LEN], *s, *t, buf2[LEN];
		return (s == t) && (t = (s = buf) + fread(buf, 1, LEN, stdin)), s == t ? -1 : *s++;
	}
	inline ioss & operator >> (long long&x) {
		static char ch, sgn, *p;
		ch = gc(), sgn = 0;
		for (; !isdigit(ch); ch = gc()) { if (ch == -1)return *this; sgn |= ch == '-'; }
		for (x = 0; isdigit(ch); ch = gc())x = x * 10 + (ch^'0');
		sgn && (x = -x); return *this;
	}
	inline ioss & operator >> (int &x) {
		static char ch, sgn, *p;
		ch = gc(), sgn = 0;
		for (; !isdigit(ch); ch = gc())
		{
			if (ch == -1)
			{
				eof = true;
				return *this;
			}
			sgn |= ch == '-'; }
		for (x = 0; isdigit(ch); ch = gc())x = x * 10 + (ch^'0');
		sgn && (x = -x); return *this;
	}
	inline ioss & operator >> (char&x)
	{
		static char ch;
		for (; !isalpha(ch) && !isdigit(ch); ch = gc())
			if (ch == -1)return *this;
		for (; isalpha(ch) || isdigit(ch); ch = gc())
			x = ch;
		return *this;
	}
	inline ioss & operator >> (string &x)
	{
		static char ch, *p, buf2[LEN];
		for (; !isalpha(ch) && !isdigit(ch); ch = gc())
			if (ch == -1)
			{
				eof = true;
				return *this;
			}
		p = buf2;
		for (; isalpha(ch) || isdigit(ch); ch = gc())
			*p = ch, p++;
		*p = '\0';
		x = buf2;
		return *this;
	}
	inline ioss & operator <<(string &c)
	{
		for (auto &p : c)
			this->operator<<(p);
		return *this;
	}
	inline ioss & operator <<(const char *c)
	{
		while (*c != '\0')
		{
			this->operator<<(*c);
			c++;
		}
		return *this;
	}
	inline ioss & operator <<(const char &c) {
		oh == obuf + LEN ? (fwrite(obuf, 1, LEN, stdout), oh = obuf) : 0;
		*oh++ = c;
		return *this;
	}
	inline ioss & operator <<(int x) {
		static int buf[30], cnt;
		if (x < 0)
			this->operator<<('-'), x = -x;
		if (x == 0)
			this->operator<<('0');
		for (cnt = 0; x; x /= 10) buf[++cnt] = x % 10 | 48;
		while (cnt) this->operator<<((char)buf[cnt--]);
		return *this;
	}
	inline ioss & operator <<(long long x) {
		static int buf[30], cnt;
		if (x < 0)
			this->operator<<('-'), x = -x;
		if (x == 0)
			this->operator<<('0');
		for (cnt = 0; x; x /= 10) buf[++cnt] = x % 10 | 48;
		while (cnt) this->operator<<((char)buf[cnt--]);
		return *this;
	}
	~ioss()
	{
		fwrite(obuf, 1, oh - obuf, stdout);
	}
} io;

int t, n;

int main()
{
    io >> t;
    while (t--) {
        io >> n;
        for (int i = 1; i <= 100000; ++i)
            io << 1;
        io << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct ioss {
#define endl '\n'
	static const int LEN = 500000;
	char obuf[LEN], *oh = obuf;
	bool eof=false;
	inline char gc() {

		static char buf[LEN], *s, *t, buf2[LEN];
		return (s == t) && (t = (s = buf) + fread(buf, 1, LEN, stdin)), s == t ? -1 : *s++;
	}
	inline ioss & operator >> (long long&x) {
		static char ch, sgn, *p;
		ch = gc(), sgn = 0;
		for (; !isdigit(ch); ch = gc()) { if (ch == -1)return *this; sgn |= ch == '-'; }
		for (x = 0; isdigit(ch); ch = gc())x = x * 10 + (ch^'0');
		sgn && (x = -x); return *this;
	}
	inline ioss & operator >> (int &x) {
		static char ch, sgn, *p;
		ch = gc(), sgn = 0;
		for (; !isdigit(ch); ch = gc())
		{
			if (ch == -1)
			{
				eof = true;
				return *this;
			}
			sgn |= ch == '-'; }
		for (x = 0; isdigit(ch); ch = gc())x = x * 10 + (ch^'0');
		sgn && (x = -x); return *this;
	}
	inline ioss & operator >> (char&x)
	{
		static char ch;
		for (; !isalpha(ch) && !isdigit(ch); ch = gc())
			if (ch == -1)return *this;
		for (; isalpha(ch) || isdigit(ch); ch = gc())
			x = ch;
		return *this;
	}
	inline ioss & operator >> (string &x)
	{
		static char ch, *p, buf2[LEN];
		for (; !isalpha(ch) && !isdigit(ch); ch = gc())
			if (ch == -1)
			{
				eof = true;
				return *this;
			}
		p = buf2;
		for (; isalpha(ch) || isdigit(ch); ch = gc())
			*p = ch, p++;
		*p = '\0';
		x = buf2;
		return *this;
	}
	inline ioss & operator <<(string &c)
	{
		for (auto &p : c)
			this->operator<<(p);
		return *this;
	}
	inline ioss & operator <<(const char *c)
	{
		while (*c != '\0')
		{
			this->operator<<(*c);
			c++;
		}
		return *this;
	}
	inline ioss & operator <<(const char &c) {
		oh == obuf + LEN ? (fwrite(obuf, 1, LEN, stdout), oh = obuf) : 0;
		*oh++ = c;
		return *this;
	}
	inline ioss & operator <<(int x) {
		static int buf[30], cnt;
		if (x < 0)
			this->operator<<('-'), x = -x;
		if (x == 0)
			this->operator<<('0');
		for (cnt = 0; x; x /= 10) buf[++cnt] = x % 10 | 48;
		while (cnt) this->operator<<((char)buf[cnt--]);
		return *this;
	}
	inline ioss & operator <<(long long x) {
		static int buf[30], cnt;
		if (x < 0)
			this->operator<<('-'), x = -x;
		if (x == 0)
			this->operator<<('0');
		for (cnt = 0; x; x /= 10) buf[++cnt] = x % 10 | 48;
		while (cnt) this->operator<<((char)buf[cnt--]);
		return *this;
	}
	~ioss()
	{
		fwrite(obuf, 1, oh - obuf, stdout);
	}
} io;

int t, n;

int main()
{
    io >> t;
    while (t--) {
        io >> n;
        if (n <= 1000) {
            for (int i = 1; i <= n; ++i)
                io << 1;
            io << 337 << '\n';
            continue;
        }
        bool flag = false;
        int a, b;
        for (int i = 2; i <= sqrt(n) + 1; ++i) {
            if (n % i == 0) {
                a = i;  b = n / i;
                flag = true;
            }
        }
        // if (flag) {
        //     for (int k = 1; k <= a; ++k) io << 1;
        //     io << 33;
        //     for (int k = 1; k <= b; ++k) io << 7;
        //     io << '\n';
        // }
        // else {
        //     int tmp = (n - 13) / 2;
        //     io << 1337;
        //     for (int i = 1; i <= tmp; ++i) io << 1;
        //     io << 3377;
        //     io << '\n';
        // }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1000000009
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>

#define MX 100000
char ans[MX];

int main()
{
	int test;
	scanf("%d", &test);

	int n, mn, x, y, z, sz;

	while(test--) {
		scanf("%d", &n);

		sz = 0;
		mn = INT_MAX;

		vector <int> v;

		while(n) {
			for(int k = 2; k <= 100000; k++) {
				ll mul = (k * (k-1)) / 2;

				if(mul <= n) {
					int diff = n - mul;

					if(diff < mn) {
						mn = diff;
						x = k;
					}
				}
			}

			n = mn;
			v.pb(x);
		}

		ans[sz++] = '7';
		for(int i = 0; i < v.back(); i++) ans[sz++] = '3';
		ans[sz++] = '1';

		for(int j = v.size()-2; j >= 0; j--) {
			for(int i = 0; i < v[j]-v[j+1]; i++) ans[sz++] = '3';
			ans[sz++] = '1';
		}

		for(int i = sz-1; i >= 0; i--) cout<<ans[i];
		cout<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1000000009
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>

#define MX 100000
char ans[MX];

int main()
{
	int test;
	scanf("%d", &test);

	int n, mn, x, y, z, sz;

	while(test--) {
		scanf("%d", &n);

		sz = 0;
		mn = INT_MAX;

		vector <int> v;

		while(n) {
			for(int k = 2; k <= 100000; k++) {
				int mul = ((ll)k * (k-1)) / 2;

				if(mul <= n) {
					int diff = n - mul;

					if(diff < mn) {
						mn = diff;
						x = k;
					}
				}
			}

			n = mn;
			v.pb(x);
		}

		ans[sz++] = '7';
		for(int i = 0; i < v.back(); i++) ans[sz++] = '3';
		ans[sz++] = '1';

		for(int j = v.size()-2; j >= 0; j--) {
			for(int i = 0; i < v[j]-v[j+1]; i++) ans[sz++] = '3';
			ans[sz++] = '1';
		}

		for(int i = sz-1; i >= 0; i--) cout<<ans[i];
		cout<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1000000009
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>

int main()
{
	int test;
	cin>>test;

	int n;
	string s = "133", ans;

	while(test--) {
		cin>>n;

		ans = s;

		while(n--) {
			ans += "7";
		}

		cout<<ans<<endl;
	}

}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1000000009
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>

int main()
{
	int test;
	cin>>test;

	string ans;
	int n, mn, x, y, z;

	while(test--) {
		cin>>n;

		ans = "";
		mn = INT_MAX;

		while(n) {
			for(int i = 1; i <= 100; i++) {
				for(int j = 1; j <= 100; j++) {
					for(int k = 1; k <= 10000; k++) {
						int mul = (i * j * k * (k-1)) / 2;

						if(mul <= n) {
							int diff = n - mul;

							if(diff < mn) {
								mn = diff;
								x = i, y = j, z = k;
							}
						}
					}
				}
			}

			n = mn;

			for(int i = 0; i < x; i++) ans += "1";
			for(int i = 0; i < z; i++) ans += "3";
			for(int i = 0; i < y; i++) ans += "7";
		}

		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1000000009
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>

#define MX 100000
char ans[MX];

int main()
{
	int test;
	scanf("%d", &test);

	int n, mn, x, y, z, sz;

	while(test--) {
		scanf("%d", &n);

		sz = 0;
		mn = INT_MAX;

		vector <int> v;

		while(n) {
			for(ll k = 2; k <= 100000; k++) {
				ll mul = (k * (k-1)) / 2;

				if(mul <= n) {
					int diff = n - mul;

					if(diff < mn) {
						mn = diff;
						x = k;
					}
				}
			}

			n = mn;
			v.pb(x);
		}

		ans[sz++] = '7';
		for(int i = 0; i < v.back(); i++) ans[sz++] = '3';
		ans[sz++] = '1';

		for(int j = v.size()-2; j >= 0; j--) {
			for(int i = 0; i < v[j]-v[j+1]; i++) ans[sz++] = '3';
			ans[sz++] = '1';
		}

		for(int i = sz-1; i >= 0; i--) cout<<ans[i];
		cout<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1000000009
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>

#define MX 100000
char ans[MX];

int main()
{
	int test;
	scanf("%d", &test);

	int n, mn, x, y, z, sz;

	while(test--) {
		scanf("%d", &n);

		sz = 0;
		mn = INT_MAX;

		while(n) {
			for(int i = 1; i <= 100; i++) {
				for(int j = 1; j <= 100; j++) {
					for(int k = 2; k <= 500; k++) {
						int mul = i * j * ((k * (k-1)) / 2);

						if(mul <= n) {
							int diff = n - mul;

							if(diff < mn) {
								mn = diff;
								x = i, y = j, z = k;
							}
						}
					}
				}
			}

			n = mn;

			for(int i = sz, j = sz+x; i < j; i++) ans[i] = '1', sz++;
			for(int i = sz, j = sz+z; i < j; i++) ans[i] = '3', sz++;
			for(int i = sz, j = sz+y; i < j; i++) ans[i] = '7', sz++;
		}

		for(int i = 0; i < sz; i++) cout<<ans[i]; cout<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1000000009
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>

#define MX 100000
char ans[MX];

int main()
{
	int test;
	scanf("%d", &test);

	ll n, mn, x, y, z, sz;

	while(test--) {
		scanf("%lld", &n);

		sz = 0;
		mn = INT_MAX;

		vector <int> v;

		while(n) {
			for(int k = 2; k <= 100000; k++) {
				ll mul = (k * (k-1)) / 2;

				if(mul <= n) {
					int diff = n - mul;

					if(diff < mn) {
						mn = diff;
						x = k;
					}
				}
			}

			n = mn;
			v.pb(x);
		}

		ans[sz++] = '7';
		for(int i = 0; i < v.back(); i++) ans[sz++] = '3';
		ans[sz++] = '1';

		for(int j = v.size()-2; j >= 0; j--) {
			for(int i = 0; i < v[j]-v[j+1]; i++) ans[sz++] = '3';
			ans[sz++] = '1';
		}

		for(int i = sz-1; i >= 0; i--) cout<<ans[i];
		cout<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1000000009
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>

#define MX 100000
char ans[MX];

int main()
{
	int test;
	scanf("%d", &test);

	int n, mn, x, y, z, sz;

	while(test--) {
		scanf("%d", &n);

		sz = 0;
		mn = INT_MAX;

		vector <int> v;

		while(n) {
			for(int k = 2; k <= 100000; k++) {
				int mul = (k * (k-1)) / 2;

				if(mul <= n) {
					int diff = n - mul;

					if(diff < mn) {
						mn = diff;
						x = k;
					}
				}
			}

			n = mn;
			v.pb(x);
		}

		ans[sz++] = '7';
		for(int i = 0; i < v.back(); i++) ans[sz++] = '3';
		ans[sz++] = '1';

		for(int j = v.size()-2; j >= 0; j--) {
			for(int i = 0; i < v[j]-v[j+1]; i++) ans[sz++] = '3';
			ans[sz++] = '1';
		}

		for(int i = sz-1; i >= 0; i--) cout<<ans[i];
		cout<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1000000009
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>

#define MX 100000
char ans[MX];

int main()
{
	int test;
	scanf("%d", &test);

	int n, mn, x, y, z, sz;

	while(test--) {
		scanf("%d", &n);

		sz = 0;
		mn = INT_MAX;

		while(n) {
			for(int i = 1; i <= 100; i++) {
				for(int j = 1; j <= 100; j++) {
					for(int k = 2; k <= 500; k++) {
						int mul = (i * j * k * (k-1)) / 2;

						if(mul <= n) {
							int diff = n - mul;

							if(diff < mn) {
								mn = diff;
								x = i, y = j, z = k;
							}
						}
					}
				}
			}

			n = mn;

			for(int i = sz, j = sz+x; i < j; i++) ans[i] = '1', sz++;
			for(int i = sz, j = sz+z; i < j; i++) ans[i] = '3', sz++;
			for(int i = sz, j = sz+y; i < j; i++) ans[i] = '7', sz++;
		}

		for(int i = 0; i < sz; i++) cout<<ans[i]; cout<<endl;
	}
}


#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
signed main() {
    int q;
    cin>>q;
    while(q--)
    {
        int n;
        cin>>n;
        int i = 0;
        if(n == 1)
        {
            cout<<1337<<endl;
            continue;
        }
        if(n == 2)
        {
            cout<<13337<<endl;
            return 0;
        }
        if(n == 3)
        {
            cout<<133737<<endl;
            return 0;
        }
        for(; i * i  + 3*i<= n; i++)
        {
            // \_(-_-)_/ flex
        }
        i--;
       deque<char> s;
       int cnt = n - (i * i + 3*i);
        s.push_front('1');
        s.push_back('3'), s.push_back('3');
        for(int j = 1; j < i; j++)
            s.push_back('1');

        for(int j = 0; j < cnt; j++)
            s.push_back('7');
        s.push_back('3'), s.push_back('3');
        for(int j = 0; j < i; j++)
            s.push_back('7');
        for(auto k : s)
            cout<<k;
        cout<<endl;
    }
}