#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e5 + 5;
vector<int> edge[N];
pair<int, int> e[N];
bool vis[N];
int sum[N];
int val[N];
int fa[N];
void dfs(int u) {
  vis[u] = 1;
  sum[u] = val[u];
  for (unsigned int i = 0; i < edge[u].size(); i++) {
    int v = edge[u][i];
    if (vis[v]) continue;
    dfs(v);
    sum[u] += sum[v];
    fa[v] = u;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  int s = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &val[i]);
    s += val[i];
  }
  if (s != 0) {
    puts("Impossible");
    return 0;
  }
  puts("Possible");
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    edge[u].push_back(v);
    edge[v].push_back(u);
    e[i].first = u;
    e[i].second = v;
  }
  dfs(1);
  for (int i = 1; i <= m; i++) {
    int x = e[i].first, y = e[i].second;
    int ans = 0;
    if (x == fa[y]) {
      ans = sum[y];
    } else if (y == fa[x]) {
      ans = -sum[x];
    }
    printf("%d\n", ans);
  }
}
