#include <bits/stdc++.h>
using namespace std;
int a[200010], head[200010], to[200010 * 2], nxt[200010 * 2], idx[200010 * 2],
    flow[200010], S[200010], rev[200010 * 2];
int n, m, eCnt, ans;
bool vis[200010];
inline int read() {
  int x = 0, flag = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') flag = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 1) + (x << 3) + (ch ^ '0');
  return x * flag;
}
inline void add(int u, int v, int i, int r) {
  eCnt++;
  nxt[eCnt] = head[u];
  to[eCnt] = v;
  idx[eCnt] = i;
  rev[eCnt] = r;
  head[u] = eCnt;
}
void DFS(int x) {
  vis[x] = true;
  S[x] = a[x];
  for (int i = head[x]; i; i = nxt[i]) {
    int y = to[i];
    if (vis[y]) continue;
    DFS(y);
    S[x] += S[y];
    if (rev[i])
      flow[idx[i]] = -S[y];
    else
      flow[idx[i]] = S[y];
  }
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  m = read();
  int u, v;
  for (int i = 1; i <= m; i++) {
    u = read(), v = read();
    add(u, v, i, 0);
    add(v, u, i, 1);
  }
  DFS(1);
  if (S[1]) {
    printf("Impossible");
    return 0;
  }
  printf("Possible\n");
  for (int i = 1; i <= m; i++) {
    printf("%d\n", flow[i]);
  }
  return 0;
}
