#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, m;
int s[N], e[N];
bool h[N];
vector<pair<int, pair<int, int> > > v[N];
void dfs(int x) {
  h[x] = 1;
  for (auto u : v[x]) {
    if (!h[u.first]) {
      dfs(u.first);
      e[u.second.first] += s[u.first] * u.second.second;
      s[x] += s[u.first];
    }
  }
}
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 x, y;
    scanf("%d %d", &x, &y);
    v[x].push_back({y, {i, +1}});
    v[y].push_back({x, {i, -1}});
  }
  dfs(1);
  if (s[1]) {
    puts("Impossible");
    return 0;
  }
  puts("Possible");
  for (int i = 1; i <= m; i++) {
    printf("%d\n", e[i]);
  }
  return 0;
}
