#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, long long> edgeno;
vector<pair<long long, long long> > adj[200010];
long long cost[200010];
long long vals[200010];
long long vis[200010];
long long dfs(long long loc) {
  vis[loc] = 1;
  for (auto &i : adj[loc]) {
    if (!vis[i.first]) {
      long long val = dfs(i.first);
      cost[loc] += val;
      vals[abs(i.second)] = ((i.second) / abs((i.second))) * val;
    }
  }
  return cost[loc];
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m, x, y;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> cost[i];
  cin >> m;
  for (long long i = 1; i <= m; i++) {
    cin >> x >> y;
    adj[x].push_back({y, i});
    adj[y].push_back({x, -i});
  }
  for (long long i = 1; i <= n; i++) {
    if (!vis[i]) {
      if (dfs(i)) {
        cout << "Impossible";
        return 0;
      }
    }
  }
  cout << "Possible\n";
  for (long long i = 1; i <= m; i++) cout << vals[i] << '\n';
  return 0;
}
