#include <bits/stdc++.h>
using namespace std;
int lg(long long n) {
  assert(n > 0);
  int ans = -1;
  while (n) {
    ans++;
    n >>= 1;
  }
  return ans;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  if (accumulate(a.begin(), a.end(), 0) != 0) {
    cout << "Impossible" << '\n';
    return;
  }
  int m;
  cin >> m;
  map<pair<int, int>, int> edgeid;
  vector<vector<int>> adj(n);
  vector<int> invert(m), ans(m);
  vector<int> outflow(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    if (u > v) {
      invert[i] = true;
      swap(u, v);
    }
    adj[u].push_back(v);
    adj[v].push_back(u);
    edgeid[make_pair(u, v)] = i;
  }
  auto getid = [&](int u, int v) {
    if (u > v) swap(u, v);
    return edgeid[make_pair(u, v)];
  };
  vector<int> vis(n);
  function<void(int, int)> dfs = [&](int cur, int fa) {
    vis[cur] = 1;
    for (int nxt : adj[cur]) {
      if (!vis[nxt]) {
        dfs(nxt, cur);
        int id = getid(cur, nxt);
        outflow[cur] += (cur < nxt ? ans[id] : -ans[id]);
      }
    }
    int id = getid(cur, fa);
    if (fa != -1)
      ans[id] = (fa < cur ? a[cur] + outflow[cur] : -(a[cur] + outflow[cur]));
  };
  dfs(0, -1);
  cout << "Possible" << '\n';
  for (int i = 0; i < m; i++) {
    cout << (invert[i] ? -ans[i] : ans[i]) << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
