#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int s[N], h[N];
bool mark[N];
vector<int> adj[N], tree[N];
int from[N], to[N], ans[N];
void DFS(int v, int p = -1) {
  mark[v] = true;
  for (auto i : adj[v]) {
    int u = from[i] + to[i] - v;
    if (mark[u]) continue;
    tree[v].push_back(i);
    DFS(u, v);
  }
}
void dfs(int v, int p = -1, int id = -1) {
  for (auto i : tree[v]) {
    int u = from[i] + to[i] - v;
    dfs(u, v, i);
    if (to[i] == v)
      s[v] -= ans[i];
    else
      s[v] += ans[i];
  }
  if (id == -1) return;
  if (to[id] == v)
    ans[id] = s[v];
  else
    ans[id] = -s[v];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    sum += s[i];
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    from[i] = u, to[i] = v;
    adj[u].push_back(i);
    adj[v].push_back(i);
  }
  if (sum != 0) return cout << "Impossible\n", 0;
  DFS(0);
  dfs(0);
  cout << "Possible\n";
  for (int i = 0; i < m; i++) cout << ans[i] << '\n';
}
