#include <bits/stdc++.h>
using namespace std;
int n, m, cnt, ssum;
int s[400010], du[400010], ehead[400010];
struct edge1 {
  int x, y, ans;
} edge[400010];
struct ed {
  int u, to, nxt;
  bool used;
} e[400010 << 1];
map<pair<int, int>, int> flow;
queue<int> q;
bool flag;
bool in[400010];
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * f;
}
inline void add(int u, int v) {
  e[++cnt].to = v;
  e[cnt].u = u;
  e[cnt].nxt = ehead[u];
  ehead[u] = cnt;
  e[cnt].used = false;
}
inline void prework() {
  n = read();
  ssum = 0;
  flag = true;
  for (int i = 1; i <= n; i++) {
    s[i] = read();
    ssum += s[i];
  }
  m = read();
  memset(ehead, 0, sizeof(ehead));
  cnt = 1;
  for (int i = 1; i <= m; i++) {
    edge[i].x = read();
    edge[i].y = read();
    edge[i].ans = 0;
    add(edge[i].x, edge[i].y);
    add(edge[i].y, edge[i].x);
  }
  if (ssum) {
    flag = false;
    return;
  }
}
inline void dfs(int u, int fa) {
  int v;
  for (int i = ehead[u]; i; i = e[i].nxt) {
    v = e[i].to;
    if (in[v]) continue;
    du[u]++;
    du[v]++;
    in[v] = true;
    e[i].used = true;
    dfs(v, u);
    pair<int, int> d = make_pair(min(u, v), max(u, v));
    if (u < v)
      flow[d] += s[v];
    else
      flow[d] -= s[v];
    s[u] += s[v];
    s[v] = 0;
  }
}
inline void mainwork() {
  if (!flag) return;
  flow.clear();
  memset(in, false, sizeof(in));
  in[1] = true;
  dfs(1, 0);
  int u, v;
  for (int i = 1; i <= m; i++) {
    u = edge[i].x;
    v = edge[i].y;
    pair<int, int> d = make_pair(min(u, v), max(u, v));
    if (flow.count(d)) {
      if (u < v)
        edge[i].ans = flow[d];
      else
        edge[i].ans = -flow[d];
    } else
      edge[i].ans = 0;
  }
}
inline void print() {
  if (flag) {
    printf("Possible\n");
    for (int i = 1; i <= m; i++) printf("%d\n", edge[i].ans);
  } else
    printf("Impossible\n");
}
int main() {
  prework();
  mainwork();
  print();
  return 0;
}
