#include <bits/stdc++.h>
using namespace std;
vector<std::vector<long long int>> graph;
map<long long int, long long int> m1;
map<pair<long long int, long long int>, long long int> m2;
vector<long long int> s;
long long int vis[(long long int)1e6 + 10];
long long int dfs(long long int u) {
  long long int sum = s[u];
  vis[u] = 1;
  for (auto &it : graph[u]) {
    if (!vis[it]) {
      long long int x = dfs(it);
      m1[m2[{u, it}]] = x;
      m1[m2[{it, u}]] = -x;
      sum += x;
    }
  }
  return sum;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long int n;
  cin >> n;
  s.assign(n + 1, 0);
  long long int sum = 0;
  for (long long int i = 1; i <= n; i++) cin >> s[i], sum += s[i];
  if (sum) return cout << "Impossible", 0;
  cout << "Possible\n";
  long long int m;
  cin >> m;
  graph.assign(n + 1, std::vector<long long int>());
  for (long long int i = 1; i <= m; i++) {
    long long int x, y;
    cin >> x >> y;
    graph[x].push_back(y);
    graph[y].push_back(x);
    m2[{x, y}] = i;
  }
  dfs(1);
  for (long long int i = 1; i <= m; i++) {
    cout << m1[i] << "\n";
  }
  return 0;
}
