#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v[200005];
long long ans[200005], cnt[200005], s[200005];
bitset<200005> is;
int DFS(int now) {
  long long tmp = 0;
  is[now] = 1;
  for (auto i : v[now]) {
    if (is[i.first]) continue;
    long long t = DFS(i.first);
    ans[abs(i.second)] = (i.second < 0 ? 1LL : -1LL) * t;
    tmp += t;
  }
  return tmp - s[now];
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n;
  long long tot = 0;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    tot += s[i];
  }
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back({b, i});
    v[b].push_back({a, -i});
  }
  if (tot != 0) return cout << "Impossible\n", 0;
  cout << "Possible\n";
  DFS(1);
  for (int i = 1; i <= m; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}
