#include <bits/stdc++.h>
using namespace std;
int s[200005];
int par[200005];
int u[200005], v[200005];
vector<pair<int, int>> way[200005];
int res[200005];
int findpar(int x) {
  if (par[x] != x) par[x] = findpar(par[x]);
  return par[x];
}
int dfs(int node, int from) {
  int sum = 0;
  for (pair<int, int> p : way[node]) {
    if (p.first == from) continue;
    int x = dfs(p.first, node);
    res[p.second] = x;
    if (node == v[p.second]) res[p.second] = -x;
    sum += x;
  }
  return s[node] + sum;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) par[i] = i;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &s[i]);
    sum += s[i];
  }
  if (sum != 0) {
    printf("Impossible");
    return 0;
  }
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u[i], &v[i]);
    if (findpar(u[i]) == findpar(v[i])) continue;
    way[u[i]].push_back({v[i], i});
    way[v[i]].push_back({u[i], i});
    par[par[u[i]]] = par[v[i]];
  }
  dfs(1, 1);
  printf("Possible\n");
  for (int i = 1; i <= m; i++) printf("%d\n", res[i]);
  return 0;
}
