#include <bits/stdc++.h>
const int N = 1000005;
int fa[N], h[N], nxt[N], adj[N], a[N], u, v, t, id[N], Id, ans[N], f[N], n, tot,
    m;
inline int fd(register int x) { return fa[x] == x ? x : fa[x] = fd(fa[x]); }
inline void add() {
  nxt[++t] = h[u], h[u] = t, adj[t] = v, id[t] = Id, nxt[++t] = h[v], h[v] = t,
  adj[t] = u, id[t] = Id;
}
inline void mer() {
  register int t1 = fd(u), t2 = fd(v);
  if (t1 != t2) fa[t1] = t2, add();
}
inline void dfs(register int x) {
  for (register int i = h[x], j; i; i = nxt[i])
    if ((j = adj[i]) != f[x])
      f[j] = x, dfs(j), a[x] += a[j], ans[id[i]] = (i & 1 ? a[j] : -a[j]);
}
inline void fr(int &num) {
  num = 0;
  char c = getchar();
  int p = 1;
  while (c < '0' || c > '9') c == '-' ? p = -1, c = getchar() : c = getchar();
  while (c >= '0' && c <= '9') num = num * 10 + c - '0', c = getchar();
  num *= p;
}
int main() {
  fr(n);
  for (register int i = 1; i <= n; ++i) fr(a[i]), tot += a[i], fa[i] = i;
  if (tot) return puts("Impossible"), 0;
  puts("Possible");
  fr(m);
  for (Id = 1; Id <= m; ++Id) fr(u), fr(v), mer();
  dfs(1);
  for (register int i = 1; i <= m; ++i) printf("%d\n", ans[i]);
  return 0;
}
