#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e7 + 8;
int spf[MAXN];
void sieve() {
  spf[1] = 1;
  for (int i = 2; i < MAXN; i++) spf[i] = i;
  for (int i = 4; i < MAXN; i += 2) spf[i] = 2;
  for (int i = 3; i * i < MAXN; i++) {
    if (spf[i] == i) {
      for (int j = i * i; j < MAXN; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  sieve();
  while (t--) {
    int n;
    cin >> n;
    vector<int> ans1(n, -1), ans2(n, -1);
    for (int i = 0; i < n; ++i) {
      int x;
      cin >> x;
      int temp = x;
      vector<int> fac;
      while (x != 1) {
        fac.push_back(spf[x]);
        x /= spf[x];
      }
      fac.resize(unique((fac).begin(), (fac).end()) - fac.begin());
      if (fac.size() > 1) {
        int p1 = 1, p2 = 1;
        for (auto j : fac) p1 *= j;
        p1 /= fac.back();
        p2 *= fac.back();
        ans1[i] = p1, ans2[i] = p2;
      }
    }
    for (auto& i : ans1) cout << i << " ";
    cout << '\n';
    for (auto& i : ans2) cout << i << " ";
  }
  return 0;
}
