#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
vector<int> pr;
void init() {
  pr.reserve(552);
  pr.push_back(2);
  pr.push_back(3);
  while (pr.back() < 4000) {
    int num = pr.back() + 2;
    int nex;
    bool flag = true;
    while (flag) {
      flag = false;
      nex = num;
      for (int i = 0; pr[i] * pr[i] <= nex; ++i) {
        if (nex % pr[i] == 0) {
          flag = true;
          break;
        }
      }
      num += 2;
    }
    pr.push_back(nex);
  }
}
int gcd(int a, int b) {
  if (a < b) {
    swap(a, b);
  }
  while (b) {
    int buf = a % b;
    a = b;
    b = buf;
  }
  return a;
}
vector<int> factors(100);
pair<int, int> func(int arg) {
  int num = arg;
  int pos = -1;
  for (int i = 0; i < pr.size(); ++i) {
    if (num % pr[i] == 0) {
      factors[++pos] = pr[i];
      while (num % pr[i] == 0) {
        num /= pr[i];
      }
    }
  }
  if (num > 1) {
    factors[++pos] = (num);
  }
  int b = factors[pos];
  int a = 1;
  for (int i = 0; i <= pos; ++i) {
    a *= factors[i];
    if (gcd(a + b, arg) == 1) {
      return {a, b};
    }
  }
  return {-1, -1};
}
void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int& e : v) {
    cin >> e;
  }
  vector<pair<int, int> > result(n);
  for (int i = 0; i < n; ++i) {
    result[i] = func(v[i]);
  }
  for (int i = 0; i < n; ++i) {
    cout << result[i].first << " ";
  }
  cout << endl;
  for (int i = 0; i < n; ++i) {
    cout << result[i].second << " ";
  }
  cout << endl;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  init();
  solve();
  return 0;
}
