#include <bits/stdc++.h>
const int N = 300010;
int n, m, i, j, js, root, mx;
int a[N], x[N], y[N], num[N], f[N], next[N * 2], last[N * 2], tov[N * 2],
    bh[N * 2], ans[N * 2];
bool dir[N * 2], bz[N];
int gf(int xx) {
  if (f[xx] == xx) return xx;
  int jl = gf(f[xx]);
  f[xx] = jl;
  return jl;
}
void ins(int xx, int yy) {
  js++;
  tov[js] = yy;
  next[js] = last[xx];
  last[xx] = js;
  bh[js] = i;
}
void suan(int t) {
  int k = last[t];
  while (k) {
    int p = tov[k];
    if (!bz[p]) {
      bz[p] = true;
      suan(p);
      if (dir[k])
        ans[bh[k]] = a[p];
      else
        ans[bh[k]] = -a[p];
      a[t] += a[p];
      a[p] = 0;
    }
    k = next[k];
  }
}
int main() {
  scanf("%d", &n);
  int l = 0;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    l += a[i];
  }
  if (l != 0) {
    printf("Impossible");
    return 0;
  }
  scanf("%d", &m);
  for (i = 1; i <= n; i++) {
    f[i] = i;
  }
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x[i], &y[i]);
    int x1 = gf(x[i]), y1 = gf(y[i]);
    if (x1 != y1) {
      ins(x[i], y[i]);
      dir[js] = true;
      ins(y[i], x[i]);
      dir[js] = false;
      f[x1] = y1;
      num[x[i]]++;
      num[y[i]]++;
    }
  }
  mx = 0;
  for (i = 1; i <= n; i++) {
    if (mx < num[i]) {
      mx = num[i];
      root = i;
    }
  }
  int bj = 0;
  memset(bz, false, sizeof(bz));
  bz[root] = true;
  suan(root);
  printf("Possible\n");
  for (i = 1; i <= m; i++) {
    printf("%d\n", ans[i]);
  }
}
