#include <bits/stdc++.h>
using namespace std;
const int maxN = (int)2e5 + 5;
const int maxM = (int)2e5 + 5;
inline int readInt() {
  char c;
  int tmp = 0, x = 1;
  c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') x = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    tmp = tmp * 10 + c - '0';
    c = getchar();
  }
  return tmp * x;
}
vector<int> g[maxN];
void addEdge(int u, int v) {
  g[u].push_back(v);
  g[v].push_back(u);
}
int Father[maxN], Ranking[maxN];
void init(int n) {
  for (int i = 1; i <= n; i++) Father[i] = i;
}
int getFather(int x) {
  return x == Father[x] ? x : Father[x] = getFather(Father[x]);
}
void mergeUnion(int u, int v) {
  int Fu = getFather(u), Fv = getFather(v);
  if (Fu == Fv) return;
  if (Ranking[Fu] > Ranking[Fv]) swap(Fu, Fv);
  Father[Fu] = Fv;
  Ranking[Fv] += Ranking[Fu];
}
int n, m, s[maxN], ans[maxM];
pair<int, int> rec[maxM];
int dep[maxN], Sum[maxN];
void dfs(int v, int fa) {
  dep[v] = (fa == -1 ? 1 : dep[fa] + 1);
  Sum[v] = s[v];
  for (int i = 0; i < (int)g[v].size(); i++) {
    if (g[v][i] != fa) dfs(g[v][i], v), Sum[v] += Sum[g[v][i]];
  }
}
int main() {
  n = readInt();
  int tot = 0;
  for (int i = 1; i <= n; i++) s[i] = readInt(), tot += s[i];
  if (tot) {
    printf("Impossible\n");
    exit(0);
  } else
    printf("Possible\n");
  m = readInt();
  init(n);
  int u, v;
  for (int i = 1; i <= m; i++) {
    u = readInt(), v = readInt();
    if (getFather(u) != getFather(v)) {
      addEdge(u, v);
      mergeUnion(u, v);
      rec[i] = make_pair(u, v);
    }
  }
  dfs(1, -1);
  for (int i = 1; i <= m; i++) {
    if (!rec[i].first && !rec[i].second) continue;
    if (dep[rec[i].first] < dep[rec[i].second])
      ans[i] = Sum[rec[i].second];
    else
      ans[i] = -Sum[rec[i].first];
  }
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return 0;
}
