#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int arr[N];
pair<int, int> arr2[N];
vector<vector<pair<int, int>>> graph(N);
map<pair<int, int>, int> mp;
bool visited[N];
int dfs(int a, int w = 0) {
  visited[a] = 1;
  w -= arr[a];
  for (int i = 0; i < graph[a].size(); i++) {
    if (!visited[graph[a][i].first]) {
      graph[a][i].second += w;
      mp[make_pair(a, graph[a][i].first)] += w;
      int w1 = dfs(graph[a][i].first, w);
      w = w1;
      mp[make_pair(a, graph[a][i].first)] -= w1;
      graph[a][i].second -= w1;
    }
  }
  return w;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    arr2[i] = make_pair(x, y);
    graph[x].push_back(make_pair(y, 0));
    graph[y].push_back(make_pair(x, 0));
  }
  int w = 0;
  for (int i = 1; i < n + 1; i++) {
    if (!visited[i]) {
      w += dfs(i);
      if (w != 0) {
        break;
      }
    }
  }
  if (w != 0) {
    cout << "Impossible\n";
  } else {
    cout << "Possible\n";
    for (int i = 0; i < m; i++) {
      int x = arr2[i].first;
      int y = arr2[i].second;
      cout << mp[make_pair(x, y)] - mp[make_pair(y, x)] << '\n';
    }
  }
  return 0;
}
