#include <bits/stdc++.h>
using namespace std;
int _[200001], __[200001], ___[200001], ____[200001];
int _____;
struct ________________ {
  int _______;
  int ________;
  int _________;
  int __________;
} ______[400001];
int _________________(int ___________) {
  return __[___________] = __[___________] == ___________
                               ? ___________
                               : _________________(__[___________]);
}
void __________________(int ___________, int ____________,
                        int _______________) {
  ______[++_____]._______ = ______[___________].________;
  ______[_____]._________ = ____________;
  ______[_____].__________ = _______________;
  ______[___________].________ = _____;
}
void ___________________(int ___________, int _______________) {
  ___[___________] = _[___________];
  for (int _____________ = ______[___________].________; _____________;
       _____________ = ______[_____________]._______)
    if (______[_____________]._________ != _______________) {
      ___________________(______[_____________]._________, ___________);
      ___[___________] += ___[______[_____________]._________];
      if (_____________ % 2)
        ____[______[_____________].__________] =
            ___[______[_____________]._________];
      else
        ____[______[_____________].__________] =
            -___[______[_____________]._________];
    }
}
int main() {
  int ______________, _______________;
  scanf("%d", &______________);
  for (int _____________ = 1; _____________ <= ______________;
       _____________++) {
    scanf("%d", &_[_____________]);
    __[_____________] = _____________;
    _____ += _[_____________];
  }
  if (_____) {
    cout << "Impossible" << endl;
    return 0;
  }
  cout << "Possible" << endl;
  _____ = 0;
  scanf("%d", &_______________);
  for (int _____________ = 1; _____________ <= _______________;
       _____________++) {
    int ___________, ____________;
    scanf("%d%d", &___________, &____________);
    if (_________________(___________) != _________________(____________)) {
      __________________(___________, ____________, _____________);
      __________________(____________, ___________, _____________);
      __[_________________(___________)] = _________________(____________);
    }
  }
  ___________________(1, 0);
  for (int _____________ = 1; _____________ <= _______________; _____________++)
    cout << ____[_____________] << endl;
  return 0;
}
