#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 100;
vector<int> g[maxn];
pair<int, int> queries[maxn];
map<pair<int, int>, int> m1;
int s[maxn];
bool vis[maxn];
void dfs(int node, int parent) {
  vis[node] = 1;
  int val = 0;
  for (auto child : g[node]) {
    if (!vis[child]) {
      dfs(child, node);
      val += m1[{child, node}];
    }
  }
  m1[{node, parent}] = val - s[node];
  m1[{parent, node}] = s[node] - val;
}
void solve() {
  int n;
  scanf("%d", &n);
  long long int sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &s[i]);
    sum += s[i];
  }
  if (sum) {
    puts("Impossible");
    return;
  }
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int n1, n2;
    scanf("%d", &n1);
    scanf("%d", &n2);
    g[n1].push_back(n2);
    g[n2].push_back(n1);
    queries[i] = {n1, n2};
  }
  vis[1] = 1;
  for (auto child : g[1]) {
    if (!vis[child]) dfs(child, 1);
  }
  puts("Possible");
  for (int i = 1; i <= m; i++) {
    printf("%d\n", m1[queries[i]]);
  }
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
