#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200000;
const int MAX_M = 200000;
int ss[MAX_N], eus[MAX_M], evs[MAX_M];
vector<pair<int, int> > nbrs[MAX_N];
int ps[MAX_N], pes[MAX_N], ds[MAX_N], cis[MAX_N];
int sss[MAX_N], fs[MAX_M];
int main() {
  int n;
  scanf("%d", &n);
  int ssum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", ss + i);
    ssum += ss[i];
  }
  if (ssum != 0) {
    puts("Impossible");
    return 0;
  }
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", eus + i, evs + i);
    eus[i]--, evs[i]--;
    nbrs[eus[i]].push_back(pair<int, int>(evs[i], i));
    nbrs[evs[i]].push_back(pair<int, int>(eus[i], i));
  }
  memset(ds, -1, sizeof(ds));
  ps[0] = pes[0] = -1, ds[0] = 0;
  for (int u = 0; u >= 0;) {
    vector<pair<int, int> > &nbru = nbrs[u];
    int up = ps[u];
    if (cis[u] < nbru.size()) {
      pair<int, int> pv = nbru[cis[u]++];
      int v = pv.first;
      if (ds[v] < 0) {
        ps[v] = u, pes[v] = pv.second;
        ds[v] = ds[u] + 1;
        u = v;
      }
    } else {
      sss[u] += ss[u];
      if (up >= 0) {
        sss[up] += sss[u];
        int ei = pes[u];
        fs[ei] = (u == eus[ei]) ? -sss[u] : sss[u];
      }
      u = up;
    }
  }
  puts("Possible");
  for (int i = 0; i < m; i++) printf("%d\n", fs[i]);
  return 0;
}
