#include <bits/stdc++.h>
using namespace std;
int setBit(int n, int pos) { return n = n | (1 << pos); }
int resetBit(int n, int pos) { return n = n & ~(1 << pos); }
bool checkBit(long long n, long long pos) { return (bool)(n & (1LL << pos)); }
const int MAX = 200010;
int ara[MAX];
vector<pair<int, int> > ed[MAX];
bool vis[MAX];
int ans[MAX];
int dfs(int s, int p) {
  vis[s] = true;
  int x, id, val;
  int ret = ara[s];
  for (int i = 0; i < ed[s].size(); i++) {
    x = ed[s][i].first;
    id = ed[s][i].second;
    if (!vis[x]) {
      val = dfs(x, s);
      ret += val;
      ans[abs(id)] += (id / abs(id)) * val;
    }
  }
  return ret;
}
int main() {
  int n, m, sum = 0, u, v;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &ara[i]);
    sum += ara[i];
  }
  if (sum != 0) {
    puts("Impossible");
    return 0;
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &u, &v);
    ed[u].push_back({v, i});
    ed[v].push_back({u, -i});
  }
  dfs(1, -1);
  puts("Possible");
  for (int i = 1; i <= m; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
