#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, m, s[N], a[N], b[N], w[N];
vector<int> adj[N];
bool mark[N];
int dfs(int u, int x) {
  mark[u] = true;
  for (int p : adj[u])
    if (!mark[a[p] ^ b[p] ^ u]) s[u] += dfs(a[p] ^ b[p] ^ u, p);
  w[x] = (a[x] ^ u ? s[u] : -s[u]);
  return s[u];
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    adj[--a[i]].push_back(i);
    adj[--b[i]].push_back(i);
  }
  for (int u = 0; u < n; u++)
    if (!mark[u] && dfs(u, m)) {
      cout << "Impossible" << endl;
      return 0;
    }
  cout << "Possible" << endl;
  for (int i = 0; i < m; i++) cout << w[i] << endl;
}
