#include <bits/stdc++.h>
using namespace std;
void chmax(int &x, int y) { x = (x > y) ? x : y; }
void chmin(int &x, int y) { x = (x < y) ? x : y; }
long long read() {
  long long tmp = 0, fh = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    tmp = tmp * 10 + ch - '0';
    ch = getchar();
  }
  return tmp * fh;
}
const int N = 600010;
struct Edge {
  int data, next, p, tag;
} e[N];
int eu[N], ev[N], ep[N], eg[N], n, m, head[N], place, id;
long long a[N], tmp, vote[N];
bool use[N];
void build(int u, int v, int p, int tag) {
  e[++place].data = v;
  e[place].next = head[u];
  head[u] = place;
  e[place].p = p;
  e[place].tag = tag;
}
void dfs(int x) {
  use[x] = true;
  for (int ed = head[x]; ed != 0; ed = e[ed].next)
    if (use[e[ed].data] == false) {
      dfs(e[ed].data);
      eu[++id] = x;
      ev[id] = e[ed].data;
      ep[id] = e[ed].p;
      eg[id] = e[ed].tag;
    }
}
void solve(int x, int fa) {
  for (int ed = head[x]; ed != 0; ed = e[ed].next)
    if (e[ed].data != fa) {
      solve(e[ed].data, x);
      long long nd = a[e[ed].data];
      vote[e[ed].p] -= nd * e[ed].tag;
      a[x] += a[e[ed].data];
    }
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read(), tmp = tmp + a[i];
  if (tmp != 0) {
    printf("Impossible\n");
    return 0;
  }
  m = read();
  for (int i = 1; i <= m; i++) {
    int eu = read(), ev = read();
    build(eu, ev, i, 1);
    build(ev, eu, i, -1);
  }
  dfs(1);
  memset(head, 0, sizeof(head));
  place = 0;
  for (int i = 1; i <= id; i++) {
    build(eu[i], ev[i], ep[i], 1 * eg[i]);
    build(ev[i], eu[i], ep[i], -1 * eg[i]);
  }
  solve(1, 0);
  printf("Possible\n");
  for (int i = 1; i <= m; i++) printf("%lld\n", -vote[i]);
  return 0;
}
