#include <bits/stdc++.h>
using namespace std;
int a[200001], fa[200001], p[200001], ans[200001];
int cnt;
struct rec {
  int nxt;
  int lst;
  int to;
  int id;
} e[400001];
int getfa(int x) { return fa[x] = fa[x] == x ? x : getfa(fa[x]); }
void add(int x, int y, int flag) {
  e[++cnt].nxt = e[x].lst;
  e[cnt].to = y;
  e[cnt].id = flag;
  e[x].lst = cnt;
}
void dfs(int x, int f) {
  p[x] = a[x];
  for (int i = e[x].lst; i; i = e[i].nxt)
    if (e[i].to != f) {
      dfs(e[i].to, x);
      p[x] += p[e[i].to];
      if (i % 2)
        ans[e[i].id] = p[e[i].to];
      else
        ans[e[i].id] = -p[e[i].to];
    }
}
int main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    fa[i] = i;
    cnt += a[i];
  }
  if (cnt) {
    cout << "Impossible" << endl;
    return 0;
  }
  cout << "Possible" << endl;
  cnt = 0;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (getfa(x) != getfa(y)) {
      add(x, y, i);
      add(y, x, i);
      fa[getfa(x)] = getfa(y);
    }
  }
  dfs(1, 0);
  for (int i = 1; i <= m; i++) cout << ans[i] << endl;
  return 0;
}
