#include <bits/stdc++.h>
using namespace std;
int ex[200005], ey[200005], r[200005];
vector<int> g[200005];
bool vis[200005];
int n, m, s[200005];
void dfs(int x, int p = -1) {
  vis[x] = true;
  for (int i : g[x]) {
    int y = ex[i] ^ ey[i] ^ x;
    if (vis[y]) continue;
    dfs(y, i);
    s[x] += s[y];
  }
  if (s[x]) {
    if (x == ex[p])
      r[p] = -s[x];
    else
      r[p] = s[x];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) scanf("%d", s + i);
  scanf("%d", &m);
  for (int i = 0, ThxDem = m; i < ThxDem; ++i) {
    scanf("%d %d", ex + i, ey + i);
    ex[i]--;
    ey[i]--;
    g[ex[i]].push_back(i);
    g[ey[i]].push_back(i);
  }
  int t = 0;
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) t += s[i];
  if (t) {
    puts("Impossible");
    return 0;
  }
  puts("Possible");
  dfs(0);
  for (int i = 0, ThxDem = m; i < ThxDem; ++i) printf("%d\n", r[i]);
  return 0;
}
