#include <bits/stdc++.h>
#pragma g++ opitmize(3)
#pragma g++ opitmize(2)
#pragma g++ opitmize("fast")
#pragma g++ opitmize("inline")
using namespace std;
int n, m, head[400010], k = -1, vis[400010], h[400010], tot = 1;
long long a[400010], f[400010], f1;
struct node {
  int to, nt, fg;
} edge[1000010];
inline void add(int u, int v, int fg) {
  edge[++k].nt = head[u];
  head[u] = k;
  edge[k].to = v;
  edge[k].fg = fg;
}
inline long long fr_dfs(int u, int fa) {
  long long tmp = 0, t = 0;
  vis[u] = 1;
  for (register int i = head[u]; ~i; i = edge[i].nt) {
    int v = edge[i].to;
    if (v == fa) continue;
    if (vis[v]) continue;
    tmp = fr_dfs(v, u);
    t += tmp;
    f[(i / 2) + 1] += tmp * edge[i ^ 1].fg;
  }
  if (a[u] < 0) {
    long long hhd = a[u];
    a[u] = 0;
    return t + hhd;
  }
  return t;
}
inline void sc_dfs(int u, int fa, long long &flow) {
  if (a[u] > 0) {
    flow += a[u];
    a[u] = 0;
  }
  vis[u] = 1;
  for (register int i = head[u]; ~i; i = edge[i].nt) {
    int v = edge[i].to;
    if (v == fa || vis[v]) continue;
    f[(i / 2) + 1] += (flow * edge[i].fg);
    sc_dfs(v, u, flow);
    f[(i / 2) + 1] += (flow * edge[i ^ 1].fg);
  }
}
int main() {
  memset(head, -1, sizeof(head));
  scanf("%d", &n);
  for (register int i = 1; i <= n; i++) scanf("%lld", &a[i]), f1 += a[i];
  int u, v;
  scanf("%d", &m);
  for (register int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    add(u, v, -1);
    add(v, u, 1);
  }
  if (f1 != 0) {
    printf("Impossible\n");
    return 0;
  }
  memset(vis, 0, sizeof(vis));
  a[1] += fr_dfs(1, 0);
  h[1] = 1;
  for (register int i = 1; i <= n; i++) {
    if (!vis[i]) {
      a[i] += fr_dfs(i, 0);
      h[++tot] = i;
    }
  }
  memset(vis, 0, sizeof(vis));
  for (register int i = 1; i <= tot; i++) {
    sc_dfs(h[i], 0, a[h[i]]);
  }
  for (register int i = 1; i <= n; i++) {
    if (a[i]) {
      printf("Impossible\n");
      return 0;
    }
  }
  printf("Possible\n");
  for (register int i = 1; i <= m; i++) printf("%lld\n", f[i]);
  return 0;
}
