import java.io.*;
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class cf1366d {

    public static void main(String[] args) throws IOException {
        int n = ri(), a[] = ria(n);
        int div[] = new int[10000005];
        for(int i = 2; i < 10000000; ++i) {
            if(div[i] == 0) {
                div[i] = i;
                int j = i + i;
                while(j <= 10000000) {
                    div[j] = i;
                    j += i;
                }
            }
        }
        int d1[] = new int[n], d2[] = new int[n];
        fill(d1, -1);
        fill(d2, -1);
        for(int i = 0; i < n; ++i) {
            if(div[a[i]] != a[i] && gcf(div[a[i]] +a[i] / div[a[i]], a[i]) == 1) {
                d1[i] = div[a[i]];
                d2[i] = a[i] / div[a[i]];
            }
        }
        prln(d1);
        prln(d2);
        close();
    }

    static int gcf(int a, int b) {
        if(b == 0) {
            return a;
        } else {
            return gcf(b, a % b);
        }
    }

    static BufferedReader __in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer input;
    static Random rand = new Random();

    // references
    // IBIG = 1e9 + 7
    // IRAND ~= 3e8
    // IMAX ~= 2e10
    // LMAX ~= 9e18
    // constants
    static final int IBIG = 1000000007;
    static final int IRAND = 327859546;
    static final int IMAX = 2147483647;
    static final int IMIN = -2147483648;
    static final long LMAX = 9223372036854775807L;
    static final long LMIN = -9223372036854775808L;
    // math util
    static int minof(int a, int b, int c) {return min(a, min(b, c));}
    static int minof(int... x) {if(x.length == 1) return x[0]; if(x.length == 2) return min(x[0], x[1]); if(x.length == 3) return min(x[0], min(x[1], x[2])); int min = x[0]; for(int i = 1; i < x.length; ++i) if(x[i] < min) min = x[i]; return min;}
    static long minof(long a, long b, long c) {return min(a, min(b, c));}
    static long minof(long... x) {if(x.length == 1) return x[0]; if(x.length == 2) return min(x[0], x[1]); if(x.length == 3) return min(x[0], min(x[1], x[2])); long min = x[0]; for(int i = 1; i < x.length; ++i) if(x[i] < min) min = x[i]; return min;}
    static int maxof(int a, int b, int c) {return max(a, max(b, c));}
    static int maxof(int... x) {if(x.length == 1) return x[0]; if(x.length == 2) return max(x[0], x[1]); if(x.length == 3) return max(x[0], max(x[1], x[2])); int max = x[0]; for(int i = 1; i < x.length; ++i) if(x[i] > max) max = x[i]; return max;}
    static long maxof(long a, long b, long c) {return max(a, max(b, c));}
    static long maxof(long... x) {if(x.length == 1) return x[0]; if(x.length == 2) return max(x[0], x[1]); if(x.length == 3) return max(x[0], max(x[1], x[2])); long max = x[0]; for(int i = 1; i < x.length; ++i) if(x[i] > max) max = x[i]; return max;}
    static int powi(int a, int b) {if(a == 0) return 0; int ans = 1; while(b > 0) {if((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static long powl(long a, int b) {if(a == 0) return 0; long ans = 1; while(b > 0) {if((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static int floori(double d) {return (int)d;}
    static int ceili(double d) {return (int)ceil(d);}
    static long floorl(double d) {return (long)d;}
    static long ceill(double d) {return (long)ceil(d);}
    static int randInt(int min, int max) {return rand.nextInt(max - min + 1) + min;}
    // array util
    static void reverse(int[] a) {for(int i = 0, n = a.length, half = n / 2; i < half; ++i) {int swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(long[] a) {for(int i = 0, n = a.length, half = n / 2; i < half; ++i) {long swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(double[] a) {for(int i = 0, n = a.length, half = n / 2; i < half; ++i) {double swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(char[] a) {for(int i = 0, n = a.length, half = n / 2; i < half; ++i) {char swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static <T> void reverse(T[] a) {for(int i = 0, n = a.length, half = n / 2; i < half; ++i) {T swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void shuffle(int[] a) {int n = a.length - 1; for(int i = 0; i < n; ++i) {int ind = randInt(i, n); int swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(long[] a) {int n = a.length - 1; for(int i = 0; i < n; ++i) {int ind = randInt(i, n); long swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(double[] a) {int n = a.length - 1; for(int i = 0; i < n; ++i) {int ind = randInt(i, n); double swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(char[] a) {int n = a.length - 1; for(int i = 0; i < n; ++i) {int ind = randInt(i, n); char swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static <T> void shuffle(T[] a) {int n = a.length - 1; for(int i = 0; i < n; ++i) {int ind = randInt(i, n); T swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void rsort(int[] a) {shuffle(a); Arrays.sort(a);}
    static void rsort(long[] a) {shuffle(a); Arrays.sort(a);}
    static void rsort(double[] a) {shuffle(a); Arrays.sort(a);}
    static void rsort(char[] a) {shuffle(a); Arrays.sort(a);}
    static <T> void rsort(T[] a) {shuffle(a); Arrays.sort(a);}
    // graph util
    static void connect(List<Collection<Integer>> g, int u, int v) {g.get(u).add(v); g.get(v).add(u);}
    // input
    static void r() throws IOException {input = new StringTokenizer(__in.readLine());}
    static int ri() throws IOException {return Integer.parseInt(__in.readLine());}
    static long rl() throws IOException {return Long.parseLong(__in.readLine());}
    static int[] ria(int n) throws IOException {int[] a = new int[n]; input = new StringTokenizer(__in.readLine()); for(int i = 0; i < n; ++i) a[i] = Integer.parseInt(input.nextToken()); return a;}
    static int[] riam1(int n) throws IOException {int[] a = new int[n]; input = new StringTokenizer(__in.readLine()); for(int i = 0; i < n; ++i) a[i] = Integer.parseInt(input.nextToken()) - 1; return a;}
    static long[] rla(int n) throws IOException {long[] a = new long[n]; input = new StringTokenizer(__in.readLine()); for(int i = 0; i < n; ++i) a[i] = Long.parseLong(input.nextToken()); return a;}
    static char[] rcha() throws IOException {return __in.readLine().toCharArray();}
    static String rline() throws IOException {return __in.readLine();}
    static int rni() throws IOException {input = new StringTokenizer(__in.readLine()); return Integer.parseInt(input.nextToken());}
    static int ni() {return Integer.parseInt(input.nextToken());}
    static long rnl() throws IOException {input = new StringTokenizer(__in.readLine()); return Long.parseLong(input.nextToken());}
    static long nl() {return Long.parseLong(input.nextToken());}
    // output
    static void pr(int i) {__out.print(i);}
    static void prln(int i) {__out.println(i);}
    static void pr(long l) {__out.print(l);}
    static void prln(long l) {__out.println(l);}
    static void pr(double d) {__out.print(d);}
    static void prln(double d) {__out.println(d);}
    static void pr(char c) {__out.print(c);}
    static void prln(char c) {__out.println(c);}
    static void pr(char[] s) {__out.print(new String(s));}
    static void prln(char[] s) {__out.println(new String(s));}
    static void pr(String s) {__out.print(s);}
    static void prln(String s) {__out.println(s);}
    static void pr(Object o) {__out.print(o);}
    static void prln(Object o) {__out.println(o);}
    static void prln() {__out.println();}
    static void pryes() {__out.println("yes");}
    static void pry() {__out.println("Yes");}
    static void prY() {__out.println("YES");}
    static void prno() {__out.println("no");}
    static void prn() {__out.println("No");}
    static void prN() {__out.println("NO");}
    static void pryesno(boolean b) {__out.println(b ? "yes" : "no");};
    static void pryn(boolean b) {__out.println(b ? "Yes" : "No");}
    static void prYN(boolean b) {__out.println(b ? "YES" : "NO");}
    static void prln(int... a) {for(int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i); __out.println(a[a.length - 1]);}
    static void prln(long... a) {for(int i = 0, len = a.length - 1; i < len; __out.print(a[i]), __out.print(' '), ++i); __out.println(a[a.length - 1]);}
    static <T> void prln(Collection<T> c) {int n = c.size() - 1; Iterator<T> iter = c.iterator(); for(int i = 0; i < n; __out.print(iter.next()), __out.print(' '), ++i); __out.println(iter.next());}
    static void h() {__out.println("hlfd");}
    static void flush() {__out.flush();}
    static void close() {__out.close();}
}


import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import static java.lang.Math.*;

public class Edu89_Solution_4 implements Runnable {

    private boolean console=false;
    private long MOD = 1000_000_007L;
    private int MAX = 1000_0005;

    int[] prime = new int[MAX];

    void sieve(){

        for(int i=0;i<MAX;++i){
            prime[i] = i;
        }

        for(int i=2;i<MAX;++i){

            long temp  = (long) i*(long) i;

            if(temp>MAX)
                continue;

            if(prime[i]==i){
                for(int j=i*i;j<MAX;j+=i){
                    prime[j] = i;
                }
            }
        }

    }

    ArrayList<Integer> getFact(int num){

        ArrayList<Integer> set = new ArrayList<>();
        while (num!=1){

            if(set.size()>0){
                if(set.get(set.size()-1)%prime[num]==0){
                    set.add(set.get(set.size()-1)*prime[num]);
                }else
                    set.add(prime[num]);
            }else
                set.add(prime[num]);
            num =  num / prime[num];

        }
        return set;
    }

    private void solve1(){

        sieve();
        int n = in.ni();
        int[] arr = arrInt(n);
        int[] num1 = new int[n];
        int[] num2 = new int[n];

        Arrays.fill(num1,-1);
        Arrays.fill(num2,-1);

        for(int i=0;i<n;++i){

            ArrayList<Integer> st = getFact(arr[i]);

            for(int j:st){
                for(int k:st){

//                    if(j==k)
//                        continue;

                    if(gcd(j+k,arr[i])==1){

                        num1[i] = j;
                        num2[i] = k;
                    }
                }
            }
        }

        for(int i=0;i<n;++i){
            out.printSp(num1[i]);
        }
        out.printLn();
        for(int i=0;i<n;++i){
            out.printSp(num2[i]);
        }

    }

    private void solve() {
        int testCases = 1;
//        testCases = in.ni();
        while (testCases-->0){
            solve1();
        }
    }

    private void add(TreeMap<Integer, Integer> map, int key){
        map.put(key,map.getOrDefault(key,0)+1);
    }

    private void remove(TreeMap<Integer,Integer> map,int key){
        if(!map.containsKey(key))
            return;
        map.put(key,map.getOrDefault(key,0)-1);
        if(map.get(key)==0)
            map.remove(key);
    }

    @Override
    public void run() {
        long time = System.currentTimeMillis();
        try {
            init();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        try {
            solve();
            out.flush();
            System.err.println(System.currentTimeMillis()-time);
            System.exit(0);
        }catch (Exception e){
            e.printStackTrace(); System.exit(1);
        }
    }

    /* -------------------- Templates and Input Classes -------------------------------*/

    private FastInput in;
    private FastOutput out;
    public static void main(String[] args) throws Exception {
        new Edu89_Solution_4().run();
//        new Thread(null, new Edu89_Solution_4(), "Main", 1 << 27).start();
    }
    private void init() throws FileNotFoundException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        try {
            if (!console && System.getProperty("user.name").equals("puneet")) {
                outputStream = new FileOutputStream("/home/puneet/Desktop/output.txt");
                inputStream = new FileInputStream("/home/puneet/Desktop/input.txt");
            }
        } catch (Exception ignored) {
        }
        out = new FastOutput(outputStream);
        in = new FastInput(inputStream);
    }
    private void maualAssert(int a,int b,int c){
        if(a<b || a>c) throw new RuntimeException();
    }
    private void maualAssert(long a,long b,long c){
        if(a<b || a>c) throw new RuntimeException();
    }
    private void sort(int[] arr) {
        List<Integer> list = new ArrayList<>();
        for (int object : arr) list.add(object);
        Collections.sort(list);
        for (int i = 0; i < list.size(); ++i) arr[i] = list.get(i);
    }
    private void sort(long[] arr) {
        List<Long> list = new ArrayList<>();
        for (long object : arr) list.add(object);
        Collections.sort(list);
        for (int i = 0; i < list.size(); ++i) arr[i] = list.get(i);
    }
    private long ModPow(long x, long y, long MOD) {
        long res = 1L;
        x = x % MOD;
        while (y >= 1L) {
            if ((y & 1L) > 0) res = (res * x) % MOD;
            x = (x * x) % MOD;
            y >>= 1L;
        }
        return res;
    }
    private int gcd(int a, int b) {
        if (a == 0) return b;
        return gcd(b % a, a);
    }
    private long gcd(long a, long b) {
        if (a == 0) return b;
        return gcd(b % a, a);
    }
    private int[] arrInt(int n){
        int[] arr=new int[n];for(int i=0;i<n;++i)arr[i]=in.ni();
        return arr;
    }
    private long[] arrLong(int n){
        long[] arr=new long[n];for(int i=0;i<n;++i)arr[i]=in.nl();
        return arr;
    }

    private int arrMax(int[] arr){
        int ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    private long arrMax(long[] arr){
        long ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    private int arrMin(int[] arr){
        int ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    private long arrMin(long[] arr){
        long ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    class FastInput { InputStream obj;
        public FastInput(InputStream obj) {
            this.obj = obj;
        }
        private byte inbuffer[] = new byte[1024];
        private int lenbuffer = 0, ptrbuffer = 0;
        private int readByte() { if (lenbuffer == -1) throw new InputMismatchException();
            if (ptrbuffer >= lenbuffer) { ptrbuffer = 0;
                try { lenbuffer = obj.read(inbuffer);
                } catch (IOException e) { throw new InputMismatchException(); } }
            if (lenbuffer <= 0) return -1;return inbuffer[ptrbuffer++]; }
        String ns() { int b = skip();StringBuilder sb = new StringBuilder();
            while (!(isSpaceChar(b))) // when nextLine, (isSpaceChar(b) && b!=' ')
            { sb.appendCodePoint(b);b = readByte(); }return sb.toString();}
        int ni() {
            int num = 0, b;boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') { minus = true;b = readByte(); }
            while (true) { if (b >= '0' && b <= '9') { num = num * 10 + (b - '0'); } else {
                return minus ? -num : num; }b = readByte(); }}
        long nl() { long num = 0;int b;boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') { minus = true;b = readByte(); }
            while (true) { if (b >= '0' && b <= '9') { num = num * 10L + (b - '0'); } else {
                return minus ? -num : num; }b = readByte(); } }
        private boolean isSpaceChar(int c) {
            return (!(c >= 33 && c <= 126));
        }
        int skip() { int b;while ((b = readByte()) != -1 && isSpaceChar(b)) ;return b; }
        float nf() {return Float.parseFloat(ns());}
        double nd() {return Double.parseDouble(ns());}
        char nc() {return (char) skip();}
    }

    class FastOutput{

        private final PrintWriter writer;

        public FastOutput(OutputStream outputStream) {
            writer = new PrintWriter(outputStream);
        }
        public PrintWriter getWriter(){
            return writer;
        }
        public void print(Object obj){
            writer.print(obj);
        }
        public void printLn(){
            writer.println();
        }
        public void printLn(Object obj){
            writer.print(obj);
            printLn();
        }
        public void printSp(Object obj){
            writer.print(obj+" ");
        }
        public void printArr(int[]  arr){
            for(int i:arr)
                printSp(i);
            printLn();
        }
        public void printArr(long[]  arr){
            for(long i:arr)
                printSp(i);
            printLn();
        }
        public void flush(){
            writer.flush();
        }
    }
}


import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import static java.lang.Math.*;

public class Edu89_Solution_4 implements Runnable {

    private boolean console=false;
    private long MOD = 1000_000_007L;
    private int MAX = 1000_0005;

    int[] prime = new int[MAX];

    void sieve(){

        for(int i=0;i<MAX;++i){
            prime[i] = i;
        }

        int maxPr = -1;

        for(int i=2;i<MAX;++i){

            long temp  = (long) i*(long) i;

            if(temp>MAX)
                continue;

            if(prime[i]==i){

                for(int j=i*i;j<MAX;j+=i){
                    prime[j] = i;
                    if(i==3137)
                        maxPr = max(maxPr,j);
                }
            }
        }

    }

    HashSet<Integer> getFact(int num){

        HashSet<Integer> set = new HashSet<>();

        while (num>1){
            set.add(prime[num]);
            num =  num/prime[num];

        }
        return set;
    }

    private void solve1(){

        sieve();
        int n = in.ni();
        int[] arr = arrInt(n);
        int[] num1 = new int[n];
        int[] num2 = new int[n];

        Arrays.fill(num1,-1);
        Arrays.fill(num2,-1);

        for(int i=0;i<n;++i){

            HashSet<Integer> st = getFact(arr[i]);

            if(st.size()>=2){
//                out.printLn(arr[i]+" "+st);
                num1[i] = st.iterator().next();

                int temp=1;

                Iterator<Integer> itr = st.iterator();
                itr.next();
                while (itr.hasNext()){
                    temp *= itr.next();
                }
                num2[i] = temp;
            }
        }

        for(int i=0;i<n;++i){
            out.printSp(num1[i]);
        }
        out.printLn();
        for(int i=0;i<n;++i){
            out.printSp(num2[i]);
        }

    }

    private void solve() {
        int testCases = 1;
//        testCases = in.ni();
        while (testCases-->0){
            solve1();
        }
    }

    private void add(TreeMap<Integer, Integer> map, int key){
        map.put(key,map.getOrDefault(key,0)+1);
    }

    private void remove(TreeMap<Integer,Integer> map,int key){
        if(!map.containsKey(key))
            return;
        map.put(key,map.getOrDefault(key,0)-1);
        if(map.get(key)==0)
            map.remove(key);
    }

    @Override
    public void run() {
        long time = System.currentTimeMillis();
        try {
            init();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        try {
            solve();
            out.flush();
            System.err.println(System.currentTimeMillis()-time);
            System.exit(0);
        }catch (Exception e){
            e.printStackTrace(); System.exit(1);
        }
    }

    /* -------------------- Templates and Input Classes -------------------------------*/

    private FastInput in;
    private FastOutput out;
    public static void main(String[] args) throws Exception {
        new Edu89_Solution_4().run();
//        new Thread(null, new Edu89_Solution_4(), "Main", 1 << 27).start();
    }
    private void init() throws FileNotFoundException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        try {
            if (!console && System.getProperty("user.name").equals("puneet")) {
                outputStream = new FileOutputStream("/home/puneet/Desktop/output.txt");
                inputStream = new FileInputStream("/home/puneet/Desktop/input.txt");
            }
        } catch (Exception ignored) {
        }
        out = new FastOutput(outputStream);
        in = new FastInput(inputStream);
    }
    private void maualAssert(int a,int b,int c){
        if(a<b || a>c) throw new RuntimeException();
    }
    private void maualAssert(long a,long b,long c){
        if(a<b || a>c) throw new RuntimeException();
    }
    private void sort(int[] arr) {
        List<Integer> list = new ArrayList<>();
        for (int object : arr) list.add(object);
        Collections.sort(list);
        for (int i = 0; i < list.size(); ++i) arr[i] = list.get(i);
    }
    private void sort(long[] arr) {
        List<Long> list = new ArrayList<>();
        for (long object : arr) list.add(object);
        Collections.sort(list);
        for (int i = 0; i < list.size(); ++i) arr[i] = list.get(i);
    }
    private long ModPow(long x, long y, long MOD) {
        long res = 1L;
        x = x % MOD;
        while (y >= 1L) {
            if ((y & 1L) > 0) res = (res * x) % MOD;
            x = (x * x) % MOD;
            y >>= 1L;
        }
        return res;
    }
    private int gcd(int a, int b) {
        if (a == 0) return b;
        return gcd(b % a, a);
    }
    private long gcd(long a, long b) {
        if (a == 0) return b;
        return gcd(b % a, a);
    }
    private int[] arrInt(int n){
        int[] arr=new int[n];for(int i=0;i<n;++i)arr[i]=in.ni();
        return arr;
    }
    private long[] arrLong(int n){
        long[] arr=new long[n];for(int i=0;i<n;++i)arr[i]=in.nl();
        return arr;
    }

    private int arrMax(int[] arr){
        int ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    private long arrMax(long[] arr){
        long ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    private int arrMin(int[] arr){
        int ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    private long arrMin(long[] arr){
        long ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    class FastInput { InputStream obj;
        public FastInput(InputStream obj) {
            this.obj = obj;
        }
        private byte inbuffer[] = new byte[1024];
        private int lenbuffer = 0, ptrbuffer = 0;
        private int readByte() { if (lenbuffer == -1) throw new InputMismatchException();
            if (ptrbuffer >= lenbuffer) { ptrbuffer = 0;
                try { lenbuffer = obj.read(inbuffer);
                } catch (IOException e) { throw new InputMismatchException(); } }
            if (lenbuffer <= 0) return -1;return inbuffer[ptrbuffer++]; }
        String ns() { int b = skip();StringBuilder sb = new StringBuilder();
            while (!(isSpaceChar(b))) // when nextLine, (isSpaceChar(b) && b!=' ')
            { sb.appendCodePoint(b);b = readByte(); }return sb.toString();}
        int ni() {
            int num = 0, b;boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') { minus = true;b = readByte(); }
            while (true) { if (b >= '0' && b <= '9') { num = num * 10 + (b - '0'); } else {
                return minus ? -num : num; }b = readByte(); }}
        long nl() { long num = 0;int b;boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') { minus = true;b = readByte(); }
            while (true) { if (b >= '0' && b <= '9') { num = num * 10L + (b - '0'); } else {
                return minus ? -num : num; }b = readByte(); } }
        private boolean isSpaceChar(int c) {
            return (!(c >= 33 && c <= 126));
        }
        int skip() { int b;while ((b = readByte()) != -1 && isSpaceChar(b)) ;return b; }
        float nf() {return Float.parseFloat(ns());}
        double nd() {return Double.parseDouble(ns());}
        char nc() {return (char) skip();}
    }

    class FastOutput{

        private final PrintWriter writer;

        public FastOutput(OutputStream outputStream) {
            writer = new PrintWriter(outputStream);
        }
        public PrintWriter getWriter(){
            return writer;
        }
        public void print(Object obj){
            writer.print(obj);
        }
        public void printLn(){
            writer.println();
        }
        public void printLn(Object obj){
            writer.print(obj);
            printLn();
        }
        public void printSp(Object obj){
            writer.print(obj+" ");
        }
        public void printArr(int[]  arr){
            for(int i:arr)
                printSp(i);
            printLn();
        }
        public void printArr(long[]  arr){
            for(long i:arr)
                printSp(i);
            printLn();
        }
        public void flush(){
            writer.flush();
        }
    }
}


import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import static java.lang.Math.*;

public class Edu89_Solution_4 implements Runnable {

    private boolean console=false;
    private long MOD = 1000_000_007L;
    private int MAX = 1000_0001;

    int[] prime = new int[MAX];

    void sieve(){

        for(int i=0;i<MAX;++i){
            prime[i] = i;
        }

        for(int i=2;i<MAX;++i){

            long temp  = (long) i*(long) i;

            if(temp>MAX)
                continue;

            if(prime[i]==i){
                for(int j=i*i;j<MAX;j+=i){
                    prime[j] = i;
                }
            }
        }

    }

    HashSet<Integer> getFact(int num){

        HashSet<Integer> set = new HashSet<>();
        while (num>1){
            set.add(prime[num]);
            num =  num/prime[num];

        }
        return set;
    }

    private void solve1(){

        sieve();
        int n = in.ni();
        int[] arr = arrInt(n);
        int[] num1 = new int[n];
        int[] num2 = new int[n];

        Arrays.fill(num1,-1);
        Arrays.fill(num2,-1);

        for(int i=0;i<n;++i){

            HashSet<Integer> st = getFact(arr[i]);

            for(int j:st){
                for(int k:st){

//                    if(j==k)
//                        continue;

                    if(gcd(j+k,arr[i])==1){

                        num1[i] = j;
                        num2[i] = k;
                    }
                }
            }
        }

        for(int i=0;i<n;++i){
            out.printSp(num1[i]);
        }
        out.printLn();
        for(int i=0;i<n;++i){
            out.printSp(num2[i]);
        }

    }

    private void solve() {
        int testCases = 1;
//        testCases = in.ni();
        while (testCases-->0){
            solve1();
        }
    }

    private void add(TreeMap<Integer, Integer> map, int key){
        map.put(key,map.getOrDefault(key,0)+1);
    }

    private void remove(TreeMap<Integer,Integer> map,int key){
        if(!map.containsKey(key))
            return;
        map.put(key,map.getOrDefault(key,0)-1);
        if(map.get(key)==0)
            map.remove(key);
    }

    @Override
    public void run() {
        long time = System.currentTimeMillis();
        try {
            init();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        try {
            solve();
            out.flush();
            System.err.println(System.currentTimeMillis()-time);
            System.exit(0);
        }catch (Exception e){
            e.printStackTrace(); System.exit(1);
        }
    }

    /* -------------------- Templates and Input Classes -------------------------------*/

    private FastInput in;
    private FastOutput out;
    public static void main(String[] args) throws Exception {
        new Edu89_Solution_4().run();
//        new Thread(null, new Edu89_Solution_4(), "Main", 1 << 27).start();
    }
    private void init() throws FileNotFoundException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        try {
            if (!console && System.getProperty("user.name").equals("puneet")) {
                outputStream = new FileOutputStream("/home/puneet/Desktop/output.txt");
                inputStream = new FileInputStream("/home/puneet/Desktop/input.txt");
            }
        } catch (Exception ignored) {
        }
        out = new FastOutput(outputStream);
        in = new FastInput(inputStream);
    }
    private void maualAssert(int a,int b,int c){
        if(a<b || a>c) throw new RuntimeException();
    }
    private void maualAssert(long a,long b,long c){
        if(a<b || a>c) throw new RuntimeException();
    }
    private void sort(int[] arr) {
        List<Integer> list = new ArrayList<>();
        for (int object : arr) list.add(object);
        Collections.sort(list);
        for (int i = 0; i < list.size(); ++i) arr[i] = list.get(i);
    }
    private void sort(long[] arr) {
        List<Long> list = new ArrayList<>();
        for (long object : arr) list.add(object);
        Collections.sort(list);
        for (int i = 0; i < list.size(); ++i) arr[i] = list.get(i);
    }
    private long ModPow(long x, long y, long MOD) {
        long res = 1L;
        x = x % MOD;
        while (y >= 1L) {
            if ((y & 1L) > 0) res = (res * x) % MOD;
            x = (x * x) % MOD;
            y >>= 1L;
        }
        return res;
    }
    private int gcd(int a, int b) {
        if (a == 0) return b;
        return gcd(b % a, a);
    }
    private long gcd(long a, long b) {
        if (a == 0) return b;
        return gcd(b % a, a);
    }
    private int[] arrInt(int n){
        int[] arr=new int[n];for(int i=0;i<n;++i)arr[i]=in.ni();
        return arr;
    }
    private long[] arrLong(int n){
        long[] arr=new long[n];for(int i=0;i<n;++i)arr[i]=in.nl();
        return arr;
    }

    private int arrMax(int[] arr){
        int ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    private long arrMax(long[] arr){
        long ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    private int arrMin(int[] arr){
        int ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    private long arrMin(long[] arr){
        long ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    class FastInput { InputStream obj;
        public FastInput(InputStream obj) {
            this.obj = obj;
        }
        private byte inbuffer[] = new byte[1024];
        private int lenbuffer = 0, ptrbuffer = 0;
        private int readByte() { if (lenbuffer == -1) throw new InputMismatchException();
            if (ptrbuffer >= lenbuffer) { ptrbuffer = 0;
                try { lenbuffer = obj.read(inbuffer);
                } catch (IOException e) { throw new InputMismatchException(); } }
            if (lenbuffer <= 0) return -1;return inbuffer[ptrbuffer++]; }
        String ns() { int b = skip();StringBuilder sb = new StringBuilder();
            while (!(isSpaceChar(b))) // when nextLine, (isSpaceChar(b) && b!=' ')
            { sb.appendCodePoint(b);b = readByte(); }return sb.toString();}
        int ni() {
            int num = 0, b;boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') { minus = true;b = readByte(); }
            while (true) { if (b >= '0' && b <= '9') { num = num * 10 + (b - '0'); } else {
                return minus ? -num : num; }b = readByte(); }}
        long nl() { long num = 0;int b;boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') { minus = true;b = readByte(); }
            while (true) { if (b >= '0' && b <= '9') { num = num * 10L + (b - '0'); } else {
                return minus ? -num : num; }b = readByte(); } }
        private boolean isSpaceChar(int c) {
            return (!(c >= 33 && c <= 126));
        }
        int skip() { int b;while ((b = readByte()) != -1 && isSpaceChar(b)) ;return b; }
        float nf() {return Float.parseFloat(ns());}
        double nd() {return Double.parseDouble(ns());}
        char nc() {return (char) skip();}
    }

    class FastOutput{

        private final PrintWriter writer;

        public FastOutput(OutputStream outputStream) {
            writer = new PrintWriter(outputStream);
        }
        public PrintWriter getWriter(){
            return writer;
        }
        public void print(Object obj){
            writer.print(obj);
        }
        public void printLn(){
            writer.println();
        }
        public void printLn(Object obj){
            writer.print(obj);
            printLn();
        }
        public void printSp(Object obj){
            writer.print(obj+" ");
        }
        public void printArr(int[]  arr){
            for(int i:arr)
                printSp(i);
            printLn();
        }
        public void printArr(long[]  arr){
            for(long i:arr)
                printSp(i);
            printLn();
        }
        public void flush(){
            writer.flush();
        }
    }
}


import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import static java.lang.Math.*;

public class Edu89_Solution_4 implements Runnable {

    private boolean console=false;
    private long MOD = 1000_000_007L;
    private int MAX = 1000_0005;

    int[] prime = new int[MAX];

    void sieve(){

        for(int i=0;i<MAX;++i){
            prime[i] = i;
        }

        for(int i=2;i<MAX;++i){

            long temp  = (long) i*(long) i;

            if(temp>MAX)
                continue;

            if(prime[i]==i){
                for(int j=i*i;j<MAX;j+=i){
                    prime[j] = i;
                }
            }
        }

    }

    ArrayList<Integer> getFact(int num){

        ArrayList<Integer> set = new ArrayList<>();
        while (num!=1){

            set.add(prime[num]);
            num =  num / prime[num];

        }
        return set;
    }

    private void solve1(){

        sieve();
        int n = in.ni();
        int[] arr = arrInt(n);
        int[] num1 = new int[n];
        int[] num2 = new int[n];

        Arrays.fill(num1,-1);
        Arrays.fill(num2,-1);

        for(int i=0;i<n;++i){

            ArrayList<Integer> st = getFact(arr[i]);

            for(int j:st){
                for(int k:st){

//                    if(j==k)
//                        continue;

                    if(gcd(j+k,arr[i])==1){

                        num1[i] = j;
                        num2[i] = k;
                    }
                }
            }
        }

        for(int i=0;i<n;++i){
            out.printSp(num1[i]);
        }
        out.printLn();
        for(int i=0;i<n;++i){
            out.printSp(num2[i]);
        }

    }

    private void solve() {
        int testCases = 1;
//        testCases = in.ni();
        while (testCases-->0){
            solve1();
        }
    }

    private void add(TreeMap<Integer, Integer> map, int key){
        map.put(key,map.getOrDefault(key,0)+1);
    }

    private void remove(TreeMap<Integer,Integer> map,int key){
        if(!map.containsKey(key))
            return;
        map.put(key,map.getOrDefault(key,0)-1);
        if(map.get(key)==0)
            map.remove(key);
    }

    @Override
    public void run() {
        long time = System.currentTimeMillis();
        try {
            init();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        try {
            solve();
            out.flush();
            System.err.println(System.currentTimeMillis()-time);
            System.exit(0);
        }catch (Exception e){
            e.printStackTrace(); System.exit(1);
        }
    }

    /* -------------------- Templates and Input Classes -------------------------------*/

    private FastInput in;
    private FastOutput out;
    public static void main(String[] args) throws Exception {
        new Edu89_Solution_4().run();
//        new Thread(null, new Edu89_Solution_4(), "Main", 1 << 27).start();
    }
    private void init() throws FileNotFoundException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        try {
            if (!console && System.getProperty("user.name").equals("puneet")) {
                outputStream = new FileOutputStream("/home/puneet/Desktop/output.txt");
                inputStream = new FileInputStream("/home/puneet/Desktop/input.txt");
            }
        } catch (Exception ignored) {
        }
        out = new FastOutput(outputStream);
        in = new FastInput(inputStream);
    }
    private void maualAssert(int a,int b,int c){
        if(a<b || a>c) throw new RuntimeException();
    }
    private void maualAssert(long a,long b,long c){
        if(a<b || a>c) throw new RuntimeException();
    }
    private void sort(int[] arr) {
        List<Integer> list = new ArrayList<>();
        for (int object : arr) list.add(object);
        Collections.sort(list);
        for (int i = 0; i < list.size(); ++i) arr[i] = list.get(i);
    }
    private void sort(long[] arr) {
        List<Long> list = new ArrayList<>();
        for (long object : arr) list.add(object);
        Collections.sort(list);
        for (int i = 0; i < list.size(); ++i) arr[i] = list.get(i);
    }
    private long ModPow(long x, long y, long MOD) {
        long res = 1L;
        x = x % MOD;
        while (y >= 1L) {
            if ((y & 1L) > 0) res = (res * x) % MOD;
            x = (x * x) % MOD;
            y >>= 1L;
        }
        return res;
    }
    private int gcd(int a, int b) {
        if (a == 0) return b;
        return gcd(b % a, a);
    }
    private long gcd(long a, long b) {
        if (a == 0) return b;
        return gcd(b % a, a);
    }
    private int[] arrInt(int n){
        int[] arr=new int[n];for(int i=0;i<n;++i)arr[i]=in.ni();
        return arr;
    }
    private long[] arrLong(int n){
        long[] arr=new long[n];for(int i=0;i<n;++i)arr[i]=in.nl();
        return arr;
    }

    private int arrMax(int[] arr){
        int ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    private long arrMax(long[] arr){
        long ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    private int arrMin(int[] arr){
        int ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    private long arrMin(long[] arr){
        long ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    class FastInput { InputStream obj;
        public FastInput(InputStream obj) {
            this.obj = obj;
        }
        private byte inbuffer[] = new byte[1024];
        private int lenbuffer = 0, ptrbuffer = 0;
        private int readByte() { if (lenbuffer == -1) throw new InputMismatchException();
            if (ptrbuffer >= lenbuffer) { ptrbuffer = 0;
                try { lenbuffer = obj.read(inbuffer);
                } catch (IOException e) { throw new InputMismatchException(); } }
            if (lenbuffer <= 0) return -1;return inbuffer[ptrbuffer++]; }
        String ns() { int b = skip();StringBuilder sb = new StringBuilder();
            while (!(isSpaceChar(b))) // when nextLine, (isSpaceChar(b) && b!=' ')
            { sb.appendCodePoint(b);b = readByte(); }return sb.toString();}
        int ni() {
            int num = 0, b;boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') { minus = true;b = readByte(); }
            while (true) { if (b >= '0' && b <= '9') { num = num * 10 + (b - '0'); } else {
                return minus ? -num : num; }b = readByte(); }}
        long nl() { long num = 0;int b;boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') { minus = true;b = readByte(); }
            while (true) { if (b >= '0' && b <= '9') { num = num * 10L + (b - '0'); } else {
                return minus ? -num : num; }b = readByte(); } }
        private boolean isSpaceChar(int c) {
            return (!(c >= 33 && c <= 126));
        }
        int skip() { int b;while ((b = readByte()) != -1 && isSpaceChar(b)) ;return b; }
        float nf() {return Float.parseFloat(ns());}
        double nd() {return Double.parseDouble(ns());}
        char nc() {return (char) skip();}
    }

    class FastOutput{

        private final PrintWriter writer;

        public FastOutput(OutputStream outputStream) {
            writer = new PrintWriter(outputStream);
        }
        public PrintWriter getWriter(){
            return writer;
        }
        public void print(Object obj){
            writer.print(obj);
        }
        public void printLn(){
            writer.println();
        }
        public void printLn(Object obj){
            writer.print(obj);
            printLn();
        }
        public void printSp(Object obj){
            writer.print(obj+" ");
        }
        public void printArr(int[]  arr){
            for(int i:arr)
                printSp(i);
            printLn();
        }
        public void printArr(long[]  arr){
            for(long i:arr)
                printSp(i);
            printLn();
        }
        public void flush(){
            writer.flush();
        }
    }
}


import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import static java.lang.Math.*;

public class Edu89_Solution_4 implements Runnable {

    private boolean console=false;
    private long MOD = 1000_000_007L;
    private int MAX = 1000_0005;

    int[] prime = new int[MAX];

    void sieve(){

        for(int i=0;i<MAX;++i){
            prime[i] = i;
        }

        for(int i=2;i<MAX;++i){

            long temp  = (long) i*(long) i;

            if(temp>MAX)
                continue;

            if(prime[i]==i){
                for(int j=i*i;j<MAX;j+=i){
                    prime[j] = i;
                }
            }
        }

    }

    HashSet<Integer> getFact(int num){

        HashSet<Integer> set = new HashSet<>();
        set.add(num);

        while (num>1){
            set.add(prime[num]);
            num =  num/prime[num];

        }
        return set;
    }

    private void solve1(){

        sieve();
        int n = in.ni();
        int[] arr = arrInt(n);
        int[] num1 = new int[n];
        int[] num2 = new int[n];

        Arrays.fill(num1,-1);
        Arrays.fill(num2,-1);

        for(int i=0;i<n;++i){

            HashSet<Integer> st = getFact(arr[i]);

            for(int j:st){
                for(int k:st){

//                    if(j==k)
//                        continue;

                    if(gcd(j+k,arr[i])==1){

                        num1[i] = j;
                        num2[i] = k;
                    }
                }
            }
        }

        for(int i=0;i<n;++i){
            out.printSp(num1[i]);
        }
        out.printLn();
        for(int i=0;i<n;++i){
            out.printSp(num2[i]);
        }

    }

    private void solve() {
        int testCases = 1;
//        testCases = in.ni();
        while (testCases-->0){
            solve1();
        }
    }

    private void add(TreeMap<Integer, Integer> map, int key){
        map.put(key,map.getOrDefault(key,0)+1);
    }

    private void remove(TreeMap<Integer,Integer> map,int key){
        if(!map.containsKey(key))
            return;
        map.put(key,map.getOrDefault(key,0)-1);
        if(map.get(key)==0)
            map.remove(key);
    }

    @Override
    public void run() {
        long time = System.currentTimeMillis();
        try {
            init();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        try {
            solve();
            out.flush();
            System.err.println(System.currentTimeMillis()-time);
            System.exit(0);
        }catch (Exception e){
            e.printStackTrace(); System.exit(1);
        }
    }

    /* -------------------- Templates and Input Classes -------------------------------*/

    private FastInput in;
    private FastOutput out;
    public static void main(String[] args) throws Exception {
        new Edu89_Solution_4().run();
//        new Thread(null, new Edu89_Solution_4(), "Main", 1 << 27).start();
    }
    private void init() throws FileNotFoundException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        try {
            if (!console && System.getProperty("user.name").equals("puneet")) {
                outputStream = new FileOutputStream("/home/puneet/Desktop/output.txt");
                inputStream = new FileInputStream("/home/puneet/Desktop/input.txt");
            }
        } catch (Exception ignored) {
        }
        out = new FastOutput(outputStream);
        in = new FastInput(inputStream);
    }
    private void maualAssert(int a,int b,int c){
        if(a<b || a>c) throw new RuntimeException();
    }
    private void maualAssert(long a,long b,long c){
        if(a<b || a>c) throw new RuntimeException();
    }
    private void sort(int[] arr) {
        List<Integer> list = new ArrayList<>();
        for (int object : arr) list.add(object);
        Collections.sort(list);
        for (int i = 0; i < list.size(); ++i) arr[i] = list.get(i);
    }
    private void sort(long[] arr) {
        List<Long> list = new ArrayList<>();
        for (long object : arr) list.add(object);
        Collections.sort(list);
        for (int i = 0; i < list.size(); ++i) arr[i] = list.get(i);
    }
    private long ModPow(long x, long y, long MOD) {
        long res = 1L;
        x = x % MOD;
        while (y >= 1L) {
            if ((y & 1L) > 0) res = (res * x) % MOD;
            x = (x * x) % MOD;
            y >>= 1L;
        }
        return res;
    }
    private int gcd(int a, int b) {
        if (a == 0) return b;
        return gcd(b % a, a);
    }
    private long gcd(long a, long b) {
        if (a == 0) return b;
        return gcd(b % a, a);
    }
    private int[] arrInt(int n){
        int[] arr=new int[n];for(int i=0;i<n;++i)arr[i]=in.ni();
        return arr;
    }
    private long[] arrLong(int n){
        long[] arr=new long[n];for(int i=0;i<n;++i)arr[i]=in.nl();
        return arr;
    }

    private int arrMax(int[] arr){
        int ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    private long arrMax(long[] arr){
        long ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    private int arrMin(int[] arr){
        int ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    private long arrMin(long[] arr){
        long ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    class FastInput { InputStream obj;
        public FastInput(InputStream obj) {
            this.obj = obj;
        }
        private byte inbuffer[] = new byte[1024];
        private int lenbuffer = 0, ptrbuffer = 0;
        private int readByte() { if (lenbuffer == -1) throw new InputMismatchException();
            if (ptrbuffer >= lenbuffer) { ptrbuffer = 0;
                try { lenbuffer = obj.read(inbuffer);
                } catch (IOException e) { throw new InputMismatchException(); } }
            if (lenbuffer <= 0) return -1;return inbuffer[ptrbuffer++]; }
        String ns() { int b = skip();StringBuilder sb = new StringBuilder();
            while (!(isSpaceChar(b))) // when nextLine, (isSpaceChar(b) && b!=' ')
            { sb.appendCodePoint(b);b = readByte(); }return sb.toString();}
        int ni() {
            int num = 0, b;boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') { minus = true;b = readByte(); }
            while (true) { if (b >= '0' && b <= '9') { num = num * 10 + (b - '0'); } else {
                return minus ? -num : num; }b = readByte(); }}
        long nl() { long num = 0;int b;boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') { minus = true;b = readByte(); }
            while (true) { if (b >= '0' && b <= '9') { num = num * 10L + (b - '0'); } else {
                return minus ? -num : num; }b = readByte(); } }
        private boolean isSpaceChar(int c) {
            return (!(c >= 33 && c <= 126));
        }
        int skip() { int b;while ((b = readByte()) != -1 && isSpaceChar(b)) ;return b; }
        float nf() {return Float.parseFloat(ns());}
        double nd() {return Double.parseDouble(ns());}
        char nc() {return (char) skip();}
    }

    class FastOutput{

        private final PrintWriter writer;

        public FastOutput(OutputStream outputStream) {
            writer = new PrintWriter(outputStream);
        }
        public PrintWriter getWriter(){
            return writer;
        }
        public void print(Object obj){
            writer.print(obj);
        }
        public void printLn(){
            writer.println();
        }
        public void printLn(Object obj){
            writer.print(obj);
            printLn();
        }
        public void printSp(Object obj){
            writer.print(obj+" ");
        }
        public void printArr(int[]  arr){
            for(int i:arr)
                printSp(i);
            printLn();
        }
        public void printArr(long[]  arr){
            for(long i:arr)
                printSp(i);
            printLn();
        }
        public void flush(){
            writer.flush();
        }
    }
}


import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import static java.lang.Math.*;

public class Edu89_Solution_4 implements Runnable {

    private boolean console=false;
    private long MOD = 1000_000_007L;
    private int MAX = 1000_0001;

    int[] prime = new int[MAX];

    void sieve(){

        for(int i=0;i<MAX;++i){
            prime[i] = i;
        }

        for(int i=2;i<MAX;++i){

            long temp  = (long) i*(long) i;

            if(temp>MAX)
                continue;

            if(prime[i]==i){
                for(int j=i*i;j<MAX;j+=i){
                    prime[j] = i;
                }
            }
        }

    }

    HashSet<Integer> getFact(int num){

        HashSet<Integer> set = new HashSet<>();
        while (num>1){
            set.add(prime[num]);
            num =  num/prime[num];

        }
        return set;
    }

    private void solve1(){

        sieve();
        int n = in.ni();
        int[] arr = arrInt(n);
        int[] num1 = new int[n];
        int[] num2 = new int[n];

        Arrays.fill(num1,-1);
        Arrays.fill(num2,-1);

        for(int i=0;i<n;++i){

            HashSet<Integer> st = getFact(arr[i]);

            for(int j:st){
                for(int k:st){

                    if(j==k)
                        continue;

                    if(gcd(j+k,arr[i])==1){

                        num1[i] = j;
                        num2[i] = k;
                    }
                }
            }
        }

        for(int i=0;i<n;++i){
            out.printSp(num1[i]);
        }
        out.printLn();
        for(int i=0;i<n;++i){
            out.printSp(num2[i]);
        }

    }

    private void solve() {
        int testCases = 1;
//        testCases = in.ni();
        while (testCases-->0){
            solve1();
        }
    }

    private void add(TreeMap<Integer, Integer> map, int key){
        map.put(key,map.getOrDefault(key,0)+1);
    }

    private void remove(TreeMap<Integer,Integer> map,int key){
        if(!map.containsKey(key))
            return;
        map.put(key,map.getOrDefault(key,0)-1);
        if(map.get(key)==0)
            map.remove(key);
    }

    @Override
    public void run() {
        long time = System.currentTimeMillis();
        try {
            init();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        try {
            solve();
            out.flush();
            System.err.println(System.currentTimeMillis()-time);
            System.exit(0);
        }catch (Exception e){
            e.printStackTrace(); System.exit(1);
        }
    }

    /* -------------------- Templates and Input Classes -------------------------------*/

    private FastInput in;
    private FastOutput out;
    public static void main(String[] args) throws Exception {
        new Edu89_Solution_4().run();
//        new Thread(null, new Edu89_Solution_4(), "Main", 1 << 27).start();
    }
    private void init() throws FileNotFoundException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        try {
            if (!console && System.getProperty("user.name").equals("puneet")) {
                outputStream = new FileOutputStream("/home/puneet/Desktop/output.txt");
                inputStream = new FileInputStream("/home/puneet/Desktop/input.txt");
            }
        } catch (Exception ignored) {
        }
        out = new FastOutput(outputStream);
        in = new FastInput(inputStream);
    }
    private void maualAssert(int a,int b,int c){
        if(a<b || a>c) throw new RuntimeException();
    }
    private void maualAssert(long a,long b,long c){
        if(a<b || a>c) throw new RuntimeException();
    }
    private void sort(int[] arr) {
        List<Integer> list = new ArrayList<>();
        for (int object : arr) list.add(object);
        Collections.sort(list);
        for (int i = 0; i < list.size(); ++i) arr[i] = list.get(i);
    }
    private void sort(long[] arr) {
        List<Long> list = new ArrayList<>();
        for (long object : arr) list.add(object);
        Collections.sort(list);
        for (int i = 0; i < list.size(); ++i) arr[i] = list.get(i);
    }
    private long ModPow(long x, long y, long MOD) {
        long res = 1L;
        x = x % MOD;
        while (y >= 1L) {
            if ((y & 1L) > 0) res = (res * x) % MOD;
            x = (x * x) % MOD;
            y >>= 1L;
        }
        return res;
    }
    private int gcd(int a, int b) {
        if (a == 0) return b;
        return gcd(b % a, a);
    }
    private long gcd(long a, long b) {
        if (a == 0) return b;
        return gcd(b % a, a);
    }
    private int[] arrInt(int n){
        int[] arr=new int[n];for(int i=0;i<n;++i)arr[i]=in.ni();
        return arr;
    }
    private long[] arrLong(int n){
        long[] arr=new long[n];for(int i=0;i<n;++i)arr[i]=in.nl();
        return arr;
    }

    private int arrMax(int[] arr){
        int ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    private long arrMax(long[] arr){
        long ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    private int arrMin(int[] arr){
        int ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    private long arrMin(long[] arr){
        long ans = arr[0];
        for(int i=1;i<arr.length;++i){
            ans = max(ans,arr[i]);
        }
        return ans;
    }

    class FastInput { InputStream obj;
        public FastInput(InputStream obj) {
            this.obj = obj;
        }
        private byte inbuffer[] = new byte[1024];
        private int lenbuffer = 0, ptrbuffer = 0;
        private int readByte() { if (lenbuffer == -1) throw new InputMismatchException();
            if (ptrbuffer >= lenbuffer) { ptrbuffer = 0;
                try { lenbuffer = obj.read(inbuffer);
                } catch (IOException e) { throw new InputMismatchException(); } }
            if (lenbuffer <= 0) return -1;return inbuffer[ptrbuffer++]; }
        String ns() { int b = skip();StringBuilder sb = new StringBuilder();
            while (!(isSpaceChar(b))) // when nextLine, (isSpaceChar(b) && b!=' ')
            { sb.appendCodePoint(b);b = readByte(); }return sb.toString();}
        int ni() {
            int num = 0, b;boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') { minus = true;b = readByte(); }
            while (true) { if (b >= '0' && b <= '9') { num = num * 10 + (b - '0'); } else {
                return minus ? -num : num; }b = readByte(); }}
        long nl() { long num = 0;int b;boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') { minus = true;b = readByte(); }
            while (true) { if (b >= '0' && b <= '9') { num = num * 10L + (b - '0'); } else {
                return minus ? -num : num; }b = readByte(); } }
        private boolean isSpaceChar(int c) {
            return (!(c >= 33 && c <= 126));
        }
        int skip() { int b;while ((b = readByte()) != -1 && isSpaceChar(b)) ;return b; }
        float nf() {return Float.parseFloat(ns());}
        double nd() {return Double.parseDouble(ns());}
        char nc() {return (char) skip();}
    }

    class FastOutput{

        private final PrintWriter writer;

        public FastOutput(OutputStream outputStream) {
            writer = new PrintWriter(outputStream);
        }
        public PrintWriter getWriter(){
            return writer;
        }
        public void print(Object obj){
            writer.print(obj);
        }
        public void printLn(){
            writer.println();
        }
        public void printLn(Object obj){
            writer.print(obj);
            printLn();
        }
        public void printSp(Object obj){
            writer.print(obj+" ");
        }
        public void printArr(int[]  arr){
            for(int i:arr)
                printSp(i);
            printLn();
        }
        public void printArr(long[]  arr){
            for(long i:arr)
                printSp(i);
            printLn();
        }
        public void flush(){
            writer.flush();
        }
    }
}


import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Reader in = new Reader();
    public static void main(String[] args) throws IOException {
        Main solver = new Main();
        solver.solve();
        out.flush();
        out.close();

    }

    static int INF = (int)1e9;
    static int maxn = (int)1e7+5;
    static int mod  = 998244353;
    static int n,m,q,k,t;

    void solve() throws IOException{

        int[] sieve = new int[maxn];
        for (int i = 0; i < maxn; i++) sieve[i] = -1;
        for (int i = 2; i < maxn; i++) {
            if (sieve[i] == -1) {
                for (int j = i; j < maxn; j+=i) {
                    if (sieve[j] == -1) sieve[j] = i;
                }
            }
        }

        n = in.nextInt();

        int[] arr = new int[n];
        for (int i = 0; i < n ; i++) arr[i] = in.nextInt();

        int[] a = new int[n];
        int[] b = new int[n];
        int tmp = 0, div = 0;
        for (int i = 0; i < n; i++) {
            div = sieve[arr[i]];
            tmp = 1;
            while (arr[i]%div == 0) {
                arr[i]/=div;
                tmp *= div;
            }

            if (arr[i] == 1) {
                a[i] = -1;
                b[i] = -1;
            } else {
                a[i] = tmp;
                b[i] = arr[i];
            }
        }

        for (int i = 0; i < n; i++) out.print(a[i]+" ");
        out.println();
        for (int i = 0; i < n; i++) out.print(b[i]+" ");
        out.println();
    }

    //<>

    static class Reader {

    private InputStream mIs;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public Reader() {
        this(System.in);
    }

    public Reader(InputStream is) {
        mIs = is;
    }

    public int read() {
        if (numChars == -1) {
            throw new InputMismatchException();

    }
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = mIs.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0) {
                return -1;
            }
        }
        return buf[curChar++];
    }

    public String nextLine() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    public String next() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

    }
}


import java.io.*;
import java.util.*;
public class Main
{
	int sieve[];
	void sieve(){
		sieve=new int[maxn+1];
		for(int i=1;i<=maxn;i++)
			sieve[i]=i;
		for(int i=2;i*i<=maxn;i++){
			if(sieve[i]==i){
				for(int j=i;j<=maxn;j+=i)
					sieve[j]=i;
			}
		}
	}
	final int maxn=(int)(1e7);
	private void solve()throws Exception
	{
		sieve();
		int n=nextInt();
		ArrayList<Integer> ans1=new ArrayList<>();
		ArrayList<Integer> ans2=new ArrayList<>();
		for(int i=1;i<=n;i++)
		{
			int a=nextInt();
			int first=-1,second=1;
			while(a>1)
			{
				int p=sieve[a];
				if(first==-1)
					first=p;
				else
					second*=p;
				while(a%p==0)
					a=a/p;
			}
			if(second==1)
			{
				ans1.add(-1);
				ans2.add(-1);
			}
			else
			{
				ans1.add(first);
				ans2.add(second);
			}
		}
		for(int i:ans1)
			out.print(i+" ");
		out.println();
		for(int i:ans2)
			out.print(i+" ");
	}

	///////////////////////////////////////////////////////////

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();

		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Input in = new Input(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		DTwoDivisors solver = new DTwoDivisors();
		solver.solve(1, in, out);
		out.close();
	}
	static class DTwoDivisors {
		public void solve(int testNumber, Input in, PrintWriter out) {
			ArrayList<Integer> primes = Sieve.sieve(10000);
			int n = in.nextInt();
			int[][] ans = new int[n][2];
			for(int i = 0; i<n; i++) {
				int cur = in.nextInt();
				ArrayList<Integer> div = new ArrayList<>();
				for(int j: primes) {
					if(cur%j==0) {
						div.add(j);
					}
				}
				if(div.size()==1) {
					ans[i][0] = ans[i][1] = -1;
				}else {
					ans[i][0] = div.get(0);
					ans[i][1] = 1;
					for(int j = 1; j<div.size(); j++) {
						ans[i][1] *= div.get(j);
					}
				}
			}
			for(int i = 0; i<2; i++) {
				for(int j = 0; j<n; j++) {
					if(j!=0) {
						out.print(" ");
					}
					out.print(ans[j][i]);
				}
				out.println();
			}
		}

	}

	static class Input {
		BufferedReader br;
		StringTokenizer st;

		public Input(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
			try {
				st = new StringTokenizer(br.readLine());
			}catch(IOException e) {
				e.printStackTrace();
			}
		}

		public boolean hasNext() {
			try {
				while(!st.hasMoreTokens()) {
					String s = br.readLine();
					if(s==null) {
						return false;
					}
					st = new StringTokenizer(s);
				}
				return true;
			}catch(Exception e) {
				return false;
			}
		}

		public String next() {
			if(!hasNext()) {
				throw new InputMismatchException();
			}
			return st.nextToken("\r\n\t\f ");
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}

	static class Sieve {
		public static ArrayList<Integer> sieve(int n) {
			ArrayList<Integer> ans = new ArrayList<>();
			boolean[] prime = new boolean[n+1];
			Arrays.fill(prime, true);
			for(int i = 2; i<=n; i++) {
				if(prime[i]) {
					ans.add(i);
				}
				for(int j = i<<1; j<=n; j += i) {
					prime[j] = false;
				}
			}
			return ans;
		}

	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Input in = new Input(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		DTwoDivisors solver = new DTwoDivisors();
		solver.solve(1, in, out);
		out.close();
	}
	static class DTwoDivisors {
		public void solve(int testNumber, Input in, PrintWriter out) {
			Prime_Factorization pf = new Prime_Factorization(10000000);
			int n = in.nextInt();
			int[][] ans = new int[n][2];
			for(int i = 0; i<n; i++) {
				int cur = in.nextInt();
				ArrayList<Integer> div = new ArrayList<>(new HashSet<>(pf.factor(cur)));
				if(div.size()==1) {
					ans[i][0] = ans[i][1] = -1;
				}else {
					ans[i][0] = div.get(0);
					ans[i][1] = 1;
					for(int j = 1; j<div.size(); j++) {
						ans[i][1] *= div.get(j);
					}
				}
			}
			for(int i = 0; i<2; i++) {
				for(int j = 0; j<n; j++) {
					if(j!=0) {
						out.print(" ");
					}
					out.print(ans[j][i]);
				}
				out.println();
			}
		}

	}

	static class Prime_Factorization {
		int[] minDiv;

		public Prime_Factorization(int n) {//n = maximum value to factorize
			minDiv = new int[n+1];
			boolean[] prime = new boolean[n+1];
			Arrays.fill(prime, true);
			for(int i = 2; i<=n; i++) {
				if(prime[i]) {
					minDiv[i] = i;
					for(int j = i<<1; j<=n; j += i) {
						if(prime[j]) {
							prime[j] = false;
							minDiv[j] = i;
						}
					}
				}
			}
		}

		public ArrayList<Integer> factor(int x) {//nondecreasing list of factors, with duplicates
			ArrayList<Integer> ans = new ArrayList<>();
			while(x>1) {
				ans.add(minDiv[x]);
				x /= minDiv[x];
			}
			return ans;
		}

	}

	static class Input {
		BufferedReader br;
		StringTokenizer st;

		public Input(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
			try {
				st = new StringTokenizer(br.readLine());
			}catch(IOException e) {
				e.printStackTrace();
			}
		}

		public boolean hasNext() {
			try {
				while(!st.hasMoreTokens()) {
					String s = br.readLine();
					if(s==null) {
						return false;
					}
					st = new StringTokenizer(s);
				}
				return true;
			}catch(Exception e) {
				return false;
			}
		}

		public String next() {
			if(!hasNext()) {
				throw new InputMismatchException();
			}
			return st.nextToken("\r\n\t\f ");
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}


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

public class Problem89D_solution {
	public static void main(String[] args) throws Exception {
		//test();
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter writer = new PrintWriter(System.out);

		int n = Integer.parseInt(reader.readLine());
		int[] a = new int[n];
		int[] b = new int[n];
		Arrays.fill(a, -1);
		Arrays.fill(b, -1);

		int[] spf = smallestPrimeFactor(10000000); // max of values

		StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
		int[] values = new int[n];
		for (int i = 0; i < n; i++) {
			values[i] = Integer.parseInt(tokenizer.nextToken());
			solve(spf, values[i], a, b, i);
		}
		for (int i = 0; i < n - 1; i++) {
			writer.print(a[i]);
			writer.print(' ');
		}
		writer.println(a[n - 1]);
		for (int i = 0; i < n - 1; i++) {
			writer.print(b[i]);
			writer.print(' ');
		}
		writer.println(b[n - 1]);

		reader.close();
		writer.close();
	}
	public static void solve(int[] spf, int value, int[] a, int b[], int i) {
		if (spf[value] == 0) {
			return; // prime
		}
		int factor = spf[value];
		while (value % factor == 0) {
			value /= factor;
		}
		if (value == 0) {
			return;
		}
		a[i] = factor;
		b[i] = value;
	}
	// array[0] = array[1] = -1
	// array[i] = 0 means it's prime
	// otherwise: array[i] = smallest prime factor
	public static int[] smallestPrimeFactor(int n) {
		int[] array = new int[n + 1]; // includes 0
		array[0] = -1;
		array[1] = -1;
		for (int i = 2; i <= n; i++) {
			if (array[i] == 0) {
				// it's prime
				for (int j = i + i; j <= n; j += i) {
					if (array[j] == 0) {
						array[j] = i;
					}
				}
			}
		}
		return array;
	}
}


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

public class Problem89D {
	public static void main(String[] args) throws Exception {
		//test();
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter writer = new PrintWriter(System.out);

		int n = Integer.parseInt(reader.readLine());
		long[] a = new long[n];
		long[] b = new long[n];
		Arrays.fill(a, -1L);
		Arrays.fill(b, -1L);

		StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
		long[] values = new long[n];
		for (int i = 0; i < n; i++) {
			values[i] = Integer.parseInt(tokenizer.nextToken());
			brute2(values[i], a, b, i);
		}
		for (int i = 0; i < n - 1; i++) {
			writer.print(a[i]);
			writer.print(' ');
		}
		writer.println(a[n - 1]);
		for (int i = 0; i < n - 1; i++) {
			writer.print(b[i]);
			writer.print(' ');
		}
		writer.println(b[n - 1]);

		reader.close();
		writer.close();
	}/*
	public static void test() {
		int n = 100;
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		int[] d = new int[n];
		Arrays.fill(a, -1);
		Arrays.fill(b, -1);
		Arrays.fill(c, -1);
		Arrays.fill(d, -1);
		int[] values = new int[n];
		for (int i = 0; i < n; i++) {
			values[i] = 2 + i;
			brute2(values[i], a, b, i);
			brute(values[i], c, d, i);
		}
		for (int i = 0; i < n; i++) {
			System.out.println(values[i] + ": " + a[i] + " " + b[i] + " ___ " + c[i] + " " + d[i]);
		}
	}
	public static void solve(int x, int[] a, int[] b, int i) {
		TreeSet<Integer> set = factor(x);
		if (set.size() <= 1) {
			return;
		}
		set.remove(x); // remove itself
		int large = set.last();
		set.remove(large);
		int large2 = set.last();
		if (gcd(large + large2, x) == 1) {
			a[i] = large;
			b[i] = large2;
		}
	}
	public static void brute(int x, int[] a, int[] b, int i) {
		TreeSet<Integer> set = factor(x);
		List<Integer> list = new ArrayList<>(set);
		for (int j = 0; j < list.size(); j++) {
			for (int k = j; k < list.size(); k++) {
				int c = list.get(j);
				int d = list.get(k);
				if (gcd(c + d, x) == 1) {
					a[i] = c;
					b[i] = d;
					return;
				}
			}
		}
	}*/
	public static void brute2(long x, long[] a, long[] b, int i) {
		TreeSet<Long> set = factor(x);
		set.add(x);
		set.remove(1L);
		List<Long> list = new ArrayList<>(set);
		for (int j = 0; j < list.size(); j++) {
			for (int k = j; k < list.size(); k++) {
				long c = list.get(j);
				long d = list.get(k);
				if (gcd(c + d, x) == 1) {
					a[i] = c;
					b[i] = d;
					return;
				}
			}
		}
	}
	public static long gcd(long p, long q) {
		while (q != 0) {
			long temp = q;
			q = p % q;
			p = temp;
		}
		return p;
	}
	public static TreeSet<Long> factor(long a) {
		TreeSet<Long> factors = new TreeSet<>();
		while (a % 2 == 0) {
			factors.add(2L);
			a /= 2;
		}
		for (long i = 3; i * i <= a; i += 2) {
			while (a % i == 0) {
				factors.add(i);
				a /= i;
			}
		}
		if (a > 2) {
			factors.add(a);
		}
		return factors;
	}/*
	public static List<Integer> factor(int a) {
		List<Integer> factors = new ArrayList<>();
		while (a % 2 == 0) {
			factors.add(2);
			a /= 2;
		}
		for (int i = 3; i * i <= a; i += 2) {
			while (a % i == 0) {
				factors.add(i);
				a /= i;
			}
		}
		return factors;
	}*/
}


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

public class Problem89D {
	public static void main(String[] args) throws Exception {
		//test();
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter writer = new PrintWriter(System.out);

		int n = Integer.parseInt(reader.readLine());
		int[] a = new int[n];
		int[] b = new int[n];
		Arrays.fill(a, -1);
		Arrays.fill(b, -1);

		StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
		int[] values = new int[n];
		for (int i = 0; i < n; i++) {
			values[i] = Integer.parseInt(tokenizer.nextToken());
			brute(values[i], a, b, i);
		}
		for (int i = 0; i < n - 1; i++) {
			writer.print(a[i]);
			writer.print(' ');
		}
		writer.println(a[n - 1]);
		for (int i = 0; i < n - 1; i++) {
			writer.print(b[i]);
			writer.print(' ');
		}
		writer.println(b[n - 1]);

		reader.close();
		writer.close();
	}
	public static void test() {
		int n = 100;
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		int[] d = new int[n];
		Arrays.fill(a, -1);
		Arrays.fill(b, -1);
		Arrays.fill(c, -1);
		Arrays.fill(d, -1);
		int[] values = new int[n];
		for (int i = 0; i < n; i++) {
			values[i] = 2 + i;
			solve(values[i], a, b, i);
			brute(values[i], c, d, i);
		}
		for (int i = 0; i < n; i++) {
			System.out.println(values[i] + ": " + a[i] + " " + b[i] + " ___ " + c[i] + " " + d[i]);
		}
	}
	public static void solve(int x, int[] a, int[] b, int i) {
		TreeSet<Integer> set = factor(x);
		if (set.size() <= 1) {
			return;
		}
		set.remove(x); // remove itself
		int large = set.last();
		set.remove(large);
		int large2 = set.last();
		if (gcd(large + large2, x) == 1) {
			a[i] = large;
			b[i] = large2;
		}
	}
	public static void brute(int x, int[] a, int[] b, int i) {
		TreeSet<Integer> set = factor(x);
		if (set.size() <= 1) {
			return;
		}
		List<Integer> list = new ArrayList<>(set);
		for (int j = 0; j < list.size(); j++) {
			for (int k = j; k < list.size(); k++) {
				int c = list.get(j);
				int d = list.get(k);
				if (gcd(c + d, x) == 1) {
					a[i] = c;
					b[i] = d;
					return;
				}
			}
		}
	}
	public static int gcd(int p, int q) {
		while (q != 0) {
			int temp = q;
			q = p % q;
			p = temp;
		}
		return p;
	}
	public static TreeSet<Integer> factor(int a) {
		TreeSet<Integer> factors = new TreeSet<>();
		while (a % 2 == 0) {
			factors.add(2);
			a /= 2;
		}
		for (int i = 3; i * i <= a; i += 2) {
			while (a % i == 0) {
				factors.add(i);
				a /= i;
			}
		}
		if (a > 2) {
			factors.add(a);
		}
		return factors;
	}/*
	public static List<Integer> factor(int a) {
		List<Integer> factors = new ArrayList<>();
		while (a % 2 == 0) {
			factors.add(2);
			a /= 2;
		}
		for (int i = 3; i * i <= a; i += 2) {
			while (a % i == 0) {
				factors.add(i);
				a /= i;
			}
		}
		return factors;
	}*/
}


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

public class Problem89D {
	public static void main(String[] args) throws Exception {
		//test();
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter writer = new PrintWriter(System.out);

		int n = Integer.parseInt(reader.readLine());
		int[] a = new int[n];
		int[] b = new int[n];
		Arrays.fill(a, -1);
		Arrays.fill(b, -1);

		StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
		int[] values = new int[n];
		for (int i = 0; i < n; i++) {
			values[i] = Integer.parseInt(tokenizer.nextToken());
			brute2(values[i], a, b, i);
		}
		for (int i = 0; i < n - 1; i++) {
			writer.print(a[i]);
			writer.print(' ');
		}
		writer.println(a[n - 1]);
		for (int i = 0; i < n - 1; i++) {
			writer.print(b[i]);
			writer.print(' ');
		}
		writer.println(b[n - 1]);

		reader.close();
		writer.close();
	}
	public static void test() {
		int n = 100;
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		int[] d = new int[n];
		Arrays.fill(a, -1);
		Arrays.fill(b, -1);
		Arrays.fill(c, -1);
		Arrays.fill(d, -1);
		int[] values = new int[n];
		for (int i = 0; i < n; i++) {
			values[i] = 2 + i;
			brute2(values[i], a, b, i);
			brute(values[i], c, d, i);
		}
		for (int i = 0; i < n; i++) {
			System.out.println(values[i] + ": " + a[i] + " " + b[i] + " ___ " + c[i] + " " + d[i]);
		}
	}
	public static void solve(int x, int[] a, int[] b, int i) {
		TreeSet<Integer> set = factor(x);
		if (set.size() <= 1) {
			return;
		}
		set.remove(x); // remove itself
		int large = set.last();
		set.remove(large);
		int large2 = set.last();
		if (gcd(large + large2, x) == 1) {
			a[i] = large;
			b[i] = large2;
		}
	}
	public static void brute(int x, int[] a, int[] b, int i) {
		TreeSet<Integer> set = factor(x);
		List<Integer> list = new ArrayList<>(set);
		for (int j = 0; j < list.size(); j++) {
			for (int k = j; k < list.size(); k++) {
				int c = list.get(j);
				int d = list.get(k);
				if (gcd(c + d, x) == 1) {
					a[i] = c;
					b[i] = d;
					return;
				}
			}
		}
	}
	public static void brute2(int x, int[] a, int[] b, int i) {
		TreeSet<Integer> set = factor(x);
		set.add(x);
		set.remove(1);
		List<Integer> list = new ArrayList<>(set);
		for (int j = 0; j < list.size(); j++) {
			for (int k = j; k < list.size(); k++) {
				int c = list.get(j);
				int d = list.get(k);
				if (gcd(c + d, x) == 1) {
					a[i] = c;
					b[i] = d;
					return;
				}
			}
		}
	}
	public static int gcd(int p, int q) {
		while (q != 0) {
			int temp = q;
			q = p % q;
			p = temp;
		}
		return p;
	}
	public static TreeSet<Integer> factor(long a) {
		TreeSet<Integer> factors = new TreeSet<>();
		while (a % 2 == 0) {
			factors.add(2);
			a /= 2;
		}
		for (long i = 3; i * i <= a; i += 2) {
			while (a % i == 0) {
				factors.add((int) i);
				a /= i;
			}
		}
		if (a > 2) {
			factors.add((int) a);
		}
		return factors;
	}/*
	public static List<Integer> factor(int a) {
		List<Integer> factors = new ArrayList<>();
		while (a % 2 == 0) {
			factors.add(2);
			a /= 2;
		}
		for (int i = 3; i * i <= a; i += 2) {
			while (a % i == 0) {
				factors.add(i);
				a /= i;
			}
		}
		return factors;
	}*/
}


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

public class Problem89D {
	public static void main(String[] args) throws Exception {
		//test();
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter writer = new PrintWriter(System.out);

		int n = Integer.parseInt(reader.readLine());
		long[] a = new long[n];
		long[] b = new long[n];
		Arrays.fill(a, -1L);
		Arrays.fill(b, -1L);

		StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
		long[] values = new long[n];
		for (int i = 0; i < n; i++) {
			values[i] = Integer.parseInt(tokenizer.nextToken());
			brute2(values[i], a, b, i);
		}
		for (int i = 0; i < n - 1; i++) {
			writer.print(a[i]);
			writer.print(' ');
		}
		writer.println(a[n - 1]);
		for (int i = 0; i < n - 1; i++) {
			writer.print(b[i]);
			writer.print(' ');
		}
		writer.println(b[n - 1]);

		reader.close();
		writer.close();
	}/*
	public static void test() {
		int n = 100;
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		int[] d = new int[n];
		Arrays.fill(a, -1);
		Arrays.fill(b, -1);
		Arrays.fill(c, -1);
		Arrays.fill(d, -1);
		int[] values = new int[n];
		for (int i = 0; i < n; i++) {
			values[i] = 2 + i;
			brute2(values[i], a, b, i);
			brute(values[i], c, d, i);
		}
		for (int i = 0; i < n; i++) {
			System.out.println(values[i] + ": " + a[i] + " " + b[i] + " ___ " + c[i] + " " + d[i]);
		}
	}
	public static void solve(int x, int[] a, int[] b, int i) {
		TreeSet<Integer> set = factor(x);
		if (set.size() <= 1) {
			return;
		}
		set.remove(x); // remove itself
		int large = set.last();
		set.remove(large);
		int large2 = set.last();
		if (gcd(large + large2, x) == 1) {
			a[i] = large;
			b[i] = large2;
		}
	}
	public static void brute(int x, int[] a, int[] b, int i) {
		TreeSet<Integer> set = factor(x);
		List<Integer> list = new ArrayList<>(set);
		for (int j = 0; j < list.size(); j++) {
			for (int k = j; k < list.size(); k++) {
				int c = list.get(j);
				int d = list.get(k);
				if (gcd(c + d, x) == 1) {
					a[i] = c;
					b[i] = d;
					return;
				}
			}
		}
	}*/
	public static void brute2(long x, long[] a, long[] b, int i) {
		TreeSet<Long> set = factor(x);
		set.add(x);
		set.remove(1L);
		List<Long> list = new ArrayList<>(set);
		for (int j = 0; j < list.size(); j++) {
			for (int k = j + 1; k < list.size(); k++) {
				long c = list.get(j);
				long d = list.get(k);
				if (gcd(c + d, x) == 1) {
					a[i] = c;
					b[i] = d;
					return;
				}
			}
		}
	}
	public static long gcd(long p, long q) {
		while (q != 0) {
			long temp = q;
			q = p % q;
			p = temp;
		}
		return p;
	}
	public static TreeSet<Long> factor(long a) {
		TreeSet<Long> factors = new TreeSet<>();
		for (long i = 2; i * i <= a; i ++) {
			if (a % i == 0) {
				factors.add(i);
				factors.add(a / i);
			}
		}
		factors.add(a);
		return factors;
	}/*
	public static List<Integer> factor(int a) {
		List<Integer> factors = new ArrayList<>();
		while (a % 2 == 0) {
			factors.add(2);
			a /= 2;
		}
		for (int i = 3; i * i <= a; i += 2) {
			while (a % i == 0) {
				factors.add(i);
				a /= i;
			}
		}
		return factors;
	}*/
}


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

public class Problem89D {
	public static void main(String[] args) throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter writer = new PrintWriter(System.out);

		int n = Integer.parseInt(reader.readLine());
		int[] a = new int[n];
		int[] b = new int[n];
		Arrays.fill(a, -1);
		Arrays.fill(b, -1);

		StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
		int[] values = new int[n];
		for (int i = 0; i < n; i++) {
			values[i] = Integer.parseInt(tokenizer.nextToken());
			solve(values[i], a, b, i);
		}
		for (int i = 0; i < n - 1; i++) {
			writer.print(a[i]);
			writer.print(' ');
		}
		writer.println(a[n - 1]);
		for (int i = 0; i < n - 1; i++) {
			writer.print(b[i]);
			writer.print(' ');
		}
		writer.println(b[n - 1]);

		reader.close();
		writer.close();
	}
	public static void solve(int x, int[] a, int[] b, int i) {
		TreeSet<Integer> set = factor(x);
		if (set.size() <= 1) {
			return;
		}
		set.remove(x); // remove itself
		int large = set.last();
		set.remove(large);
		int large2 = set.last();
		if (gcd(large + large2, x) == 1) {
			a[i] = large;
			b[i] = large2;
		}
	}
	public static int gcd(int p, int q) {
		while (q != 0) {
			int temp = q;
			q = p % q;
			p = temp;
		}
		return p;
	}
	public static TreeSet<Integer> factor(int a) {
		TreeSet<Integer> factors = new TreeSet<>();
		while (a % 2 == 0) {
			factors.add(2);
			a /= 2;
		}
		for (int i = 3; i * i <= a; i += 2) {
			while (a % i == 0) {
				factors.add(i);
				a /= i;
			}
		}
		if (a > 2) {
			factors.add(a);
		}
		return factors;
	}/*
	public static List<Integer> factor(int a) {
		List<Integer> factors = new ArrayList<>();
		while (a % 2 == 0) {
			factors.add(2);
			a /= 2;
		}
		for (int i = 3; i * i <= a; i += 2) {
			while (a % i == 0) {
				factors.add(i);
				a /= i;
			}
		}
		return factors;
	}*/
}


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

public class Problem89D {
	public static void main(String[] args) throws Exception {
		//test();
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter writer = new PrintWriter(System.out);

		int n = Integer.parseInt(reader.readLine());
		long[] a = new long[n];
		long[] b = new long[n];
		Arrays.fill(a, -1L);
		Arrays.fill(b, -1L);

		StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
		long[] values = new long[n];
		for (int i = 0; i < n; i++) {
			values[i] = Integer.parseInt(tokenizer.nextToken());
			brute2(values[i], a, b, i);
		}
		for (int i = 0; i < n - 1; i++) {
			writer.print(a[i]);
			writer.print(' ');
		}
		writer.println(a[n - 1]);
		for (int i = 0; i < n - 1; i++) {
			writer.print(b[i]);
			writer.print(' ');
		}
		writer.println(b[n - 1]);

		reader.close();
		writer.close();
	}/*
	public static void test() {
		int n = 100;
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		int[] d = new int[n];
		Arrays.fill(a, -1);
		Arrays.fill(b, -1);
		Arrays.fill(c, -1);
		Arrays.fill(d, -1);
		int[] values = new int[n];
		for (int i = 0; i < n; i++) {
			values[i] = 2 + i;
			brute2(values[i], a, b, i);
			brute(values[i], c, d, i);
		}
		for (int i = 0; i < n; i++) {
			System.out.println(values[i] + ": " + a[i] + " " + b[i] + " ___ " + c[i] + " " + d[i]);
		}
	}
	public static void solve(int x, int[] a, int[] b, int i) {
		TreeSet<Integer> set = factor(x);
		if (set.size() <= 1) {
			return;
		}
		set.remove(x); // remove itself
		int large = set.last();
		set.remove(large);
		int large2 = set.last();
		if (gcd(large + large2, x) == 1) {
			a[i] = large;
			b[i] = large2;
		}
	}
	public static void brute(int x, int[] a, int[] b, int i) {
		TreeSet<Integer> set = factor(x);
		List<Integer> list = new ArrayList<>(set);
		for (int j = 0; j < list.size(); j++) {
			for (int k = j; k < list.size(); k++) {
				int c = list.get(j);
				int d = list.get(k);
				if (gcd(c + d, x) == 1) {
					a[i] = c;
					b[i] = d;
					return;
				}
			}
		}
	}*/
	public static void brute2(long x, long[] a, long[] b, int i) {
		TreeSet<Long> set = factor(x);
		set.add(x);
		set.remove(1L);
		List<Long> list = new ArrayList<>(set);
		for (int j = 0; j < list.size(); j++) {
			for (int k = j + 1; k < list.size(); k++) {
				long c = list.get(j);
				long d = list.get(k);
				if (gcd(c + d, x) == 1) {
					a[i] = c;
					b[i] = d;
					return;
				}
			}
		}
	}
	public static long gcd(long p, long q) {
		while (q != 0) {
			long temp = q;
			q = p % q;
			p = temp;
		}
		return p;
	}
	public static TreeSet<Long> factor(long a) {
		TreeSet<Long> factors = new TreeSet<>();
		if (a % 2 == 0) {
			factors.add(2L);
		}
		for (long i = 3; i * i <= a; i += 2) {
			if (a % i == 0) {
				factors.add(i);
			}
		}
		factors.add(a);
		return factors;
	}/*
	public static List<Integer> factor(int a) {
		List<Integer> factors = new ArrayList<>();
		while (a % 2 == 0) {
			factors.add(2);
			a /= 2;
		}
		for (int i = 3; i * i <= a; i += 2) {
			while (a % i == 0) {
				factors.add(i);
				a /= i;
			}
		}
		return factors;
	}*/
}


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

public class Problem89D_solution {
	public static void main(String[] args) throws Exception {
		//test();
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter writer = new PrintWriter(System.out);

		int n = Integer.parseInt(reader.readLine());
		int[] a = new int[n];
		int[] b = new int[n];
		Arrays.fill(a, -1);
		Arrays.fill(b, -1);

		int[] spf = smallestPrimeFactor(10000000); // max of values

		StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
		int[] values = new int[n];
		for (int i = 0; i < n; i++) {
			values[i] = Integer.parseInt(tokenizer.nextToken());
			solve(spf, values[i], a, b, i);
		}
		for (int i = 0; i < n - 1; i++) {
			writer.print(a[i]);
			writer.print(' ');
		}
		writer.println(a[n - 1]);
		for (int i = 0; i < n - 1; i++) {
			writer.print(b[i]);
			writer.print(' ');
		}
		writer.println(b[n - 1]);

		reader.close();
		writer.close();
	}
	public static void solve(int[] spf, int value, int[] a, int b[], int i) {
		if (spf[value] == 0) {
			return; // prime
		}
		int factor = spf[value];
		while (value % factor == 0) {
			value /= factor;
		}
		if (value == 1) {
			return;
		}
		a[i] = factor;
		b[i] = value;
	}
	// array[0] = array[1] = -1
	// array[i] = 0 means it's prime
	// otherwise: array[i] = smallest prime factor
	public static int[] smallestPrimeFactor(int n) {
		int[] array = new int[n + 1]; // includes 0
		array[0] = -1;
		array[1] = -1;
		for (int i = 2; i <= n; i++) {
			if (array[i] == 0) {
				// it's prime
				for (int j = i + i; j <= n; j += i) {
					if (array[j] == 0) {
						array[j] = i;
					}
				}
			}
		}
		return array;
	}
}


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

public class Problem89D_solution {
	public static void main(String[] args) throws Exception {
		//test();
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter writer = new PrintWriter(System.out);

		int n = Integer.parseInt(reader.readLine());
		int[] a = new int[n];
		int[] b = new int[n];
		Arrays.fill(a, -1);
		Arrays.fill(b, -1);

		int[] spf = smallestPrimeFactor2(10000000); // max of values

		StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
		int[] values = new int[n];
		for (int i = 0; i < n; i++) {
			values[i] = Integer.parseInt(tokenizer.nextToken());
			solve(spf, values[i], a, b, i);
		}
		for (int i = 0; i < n - 1; i++) {
			writer.print(a[i]);
			writer.print(' ');
		}
		writer.println(a[n - 1]);
		for (int i = 0; i < n - 1; i++) {
			writer.print(b[i]);
			writer.print(' ');
		}
		writer.println(b[n - 1]);

		reader.close();
		writer.close();
	}
	public static void solve(int[] spf, int value, int[] a, int b[], int i) {
		if (spf[value] == 0) {
			return; // prime
		}
		int factor = spf[value];
		while (value % factor == 0) {
			value /= factor;
		}
		if (value == 1) {
			return;
		}
		a[i] = factor;
		b[i] = value;
	}
	// array[0] = array[1] = -1
	// array[i] = 0 means it's prime
	// otherwise: array[i] = smallest prime factor
	// O(n log log n)
	public static int[] smallestPrimeFactor(int n) {
		int[] array = new int[n + 1]; // includes 0
		array[0] = -1;
		array[1] = -1;
		for (int i = 2; i <= n; i++) {
			if (array[i] == 0) {
				// it's prime
				for (int j = i + i; j <= n; j += i) {
					if (array[j] == 0) {
						array[j] = i;
					}
				}
			}
		}
		return array;
	}
	// O(n log log n)
	public static int[] smallestPrimeFactor2(int n) {
		int[] spf = new int[n + 1]; // includes 0
		spf[0] = -1;
		spf[1] = -1;
		for (int i = 2; i <= n; i++) {
			spf[i] = i;
		}
		for (int i = 4; i <= n; i += 2) {
			spf[i] = 2;
		}
		for (int i = 3; i * i <= n; i += 2) {
			if (spf[i] == i) {
				// prime
				for (int j = i * i; j <= n; j += i) {
					if (spf[j] == j) {
						spf[j] = i;
					}
				}
			}
		}
		return spf;
	}
}


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

public class Problem89D {
	public static void main(String[] args) throws Exception {
		//test();
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter writer = new PrintWriter(System.out);

		int n = Integer.parseInt(reader.readLine());
		long[] a = new long[n];
		long[] b = new long[n];
		Arrays.fill(a, -1L);
		Arrays.fill(b, -1L);

		StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
		long[] values = new long[n];
		for (int i = 0; i < n; i++) {
			values[i] = Integer.parseInt(tokenizer.nextToken());
			brute2(values[i], a, b, i);
		}
		for (int i = 0; i < n - 1; i++) {
			writer.print(a[i]);
			writer.print(' ');
		}
		writer.println(a[n - 1]);
		for (int i = 0; i < n - 1; i++) {
			writer.print(b[i]);
			writer.print(' ');
		}
		writer.println(b[n - 1]);

		reader.close();
		writer.close();
	}/*
	public static void test() {
		int n = 100;
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		int[] d = new int[n];
		Arrays.fill(a, -1);
		Arrays.fill(b, -1);
		Arrays.fill(c, -1);
		Arrays.fill(d, -1);
		int[] values = new int[n];
		for (int i = 0; i < n; i++) {
			values[i] = 2 + i;
			brute2(values[i], a, b, i);
			brute(values[i], c, d, i);
		}
		for (int i = 0; i < n; i++) {
			System.out.println(values[i] + ": " + a[i] + " " + b[i] + " ___ " + c[i] + " " + d[i]);
		}
	}
	public static void solve(int x, int[] a, int[] b, int i) {
		TreeSet<Integer> set = factor(x);
		if (set.size() <= 1) {
			return;
		}
		set.remove(x); // remove itself
		int large = set.last();
		set.remove(large);
		int large2 = set.last();
		if (gcd(large + large2, x) == 1) {
			a[i] = large;
			b[i] = large2;
		}
	}
	public static void brute(int x, int[] a, int[] b, int i) {
		TreeSet<Integer> set = factor(x);
		List<Integer> list = new ArrayList<>(set);
		for (int j = 0; j < list.size(); j++) {
			for (int k = j; k < list.size(); k++) {
				int c = list.get(j);
				int d = list.get(k);
				if (gcd(c + d, x) == 1) {
					a[i] = c;
					b[i] = d;
					return;
				}
			}
		}
	}*/
	public static void brute2(long x, long[] a, long[] b, int i) {
		TreeSet<Long> set = factor(x);
		set.add(x);
		set.remove(1L);
		List<Long> list = new ArrayList<>(set);
		for (int j = 0; j < list.size(); j++) {
			for (int k = j + 1; k < list.size(); k++) {
				long c = list.get(j);
				long d = list.get(k);
				if (gcd(c + d, x) == 1) {
					a[i] = c;
					b[i] = d;
					return;
				}
			}
		}
	}
	public static long gcd(long p, long q) {
		while (q != 0) {
			long temp = q;
			q = p % q;
			p = temp;
		}
		return p;
	}
	public static TreeSet<Long> factor(long a) {
		TreeSet<Long> factors = new TreeSet<>();
		while (a % 2 == 0) {
			factors.add(2L);
			a /= 2;
		}
		for (long i = 3; i * i <= a; i += 2) {
			while (a % i == 0) {
				factors.add(i);
				a /= i;
			}
		}
		if (a > 2) {
			factors.add(a);
		}
		return factors;
	}/*
	public static List<Integer> factor(int a) {
		List<Integer> factors = new ArrayList<>();
		while (a % 2 == 0) {
			factors.add(2);
			a /= 2;
		}
		for (int i = 3; i * i <= a; i += 2) {
			while (a % i == 0) {
				factors.add(i);
				a /= i;
			}
		}
		return factors;
	}*/
}