#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
mt19937 rnd(22);
int n;
long long a[MAXN];
vector<pair<int, int>> graph[MAXN];
vector<pair<int, int>> edges;
bool used[MAXN];
int parent[MAXN], parentEdge[MAXN];
set<int> treeEdges;
long long answer[MAXN];
int root;
vector<int> levelNodes[MAXN];
void DFS(int x, int level) {
  used[x] = true;
  levelNodes[level].push_back(x);
  for (pair<int, int> item : graph[x]) {
    int y = item.first;
    int edgeInd = item.second;
    if (used[y] == false) {
      treeEdges.insert(edgeInd);
      parent[y] = x;
      parentEdge[y] = edgeInd;
      DFS(y, level + 1);
    }
  }
}
void Arbeit() {
  for (int i = n; i >= 2; i--) {
    for (int x : levelNodes[i]) {
      if (edges[parentEdge[x]] == make_pair(parent[x], x)) {
        answer[parentEdge[x]] = a[x];
        a[parent[x]] += a[x];
        a[x] -= a[x];
      } else {
        answer[parentEdge[x]] = -a[x];
        a[parent[x]] -= -a[x];
        a[x] += -a[x];
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    graph[x].push_back({y, i});
    graph[y].push_back({x, i});
    edges.push_back({x, y});
  }
  long long sum = 0;
  for (int i = 1; i <= n; i++) sum += a[i];
  root = -1;
  for (int x = 1; x <= n; x++) {
    if (sum - a[x] == -a[x]) {
      root = x;
      break;
    }
  }
  if (root == -1) {
    cout << "Impossible" << '\n';
    return 0;
  }
  DFS(root, 1);
  for (int x = 1; x <= n; x++) graph[x].clear();
  for (int i = 0; i < m; i++) {
    if (treeEdges.count(i) == true) {
      graph[edges[i].first].push_back({edges[i].second, i});
      graph[edges[i].second].push_back({edges[i].first, i});
    }
  }
  Arbeit();
  if (a[root] != 0) {
    cout << "Impossible " << '\n';
    return 0;
  }
  cout << "Possible" << '\n';
  for (int i = 0; i < m; i++) cout << answer[i] << '\n';
}
