#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n;
int s[maxn];
int m;
vector<pair<int, int> > adj[maxn];
bool used[maxn];
int f[maxn];
int dfs(int u) {
  used[u] = true;
  int total = s[u];
  for (int i = 0; i < adj[u].size(); ++i) {
    int v = adj[u][i].first;
    int w = adj[u][i].second;
    if (!used[v]) {
      int sum = dfs(v);
      total += sum;
      f[abs(w)] = w / abs(w) * sum;
    }
  }
  return total;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", s + i);
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(pair<int, int>(v, i));
    adj[v].push_back(pair<int, int>(u, -i));
  }
  for (int i = 1; i <= n; ++i) {
    if (!used[i] && dfs(i) != 0) {
      puts("Impossible");
      return 0;
    }
  }
  puts("Possible");
  for (int i = 1; i <= m; ++i) {
    printf("%d\n", f[i]);
  }
  return 0;
}
