// https://omegaup.com/arena/problem/Operaciones-aritmeticas-entre-en/
#include <iostream>

int main( ) {
   int n;
   std::cin >> n;

   int a[100];
   for (int i = 0; i < n; ++i) {
      std::cin >> a[i];
   }

   int m;
   std::cin >> m;

   for (int i = 0; i < m; ++i) {
      char c; int x, y, z;
      std::cin >> c >> x >> y >> z;

      if (c == '+') {
         a[x] = a[y] + a[z];
      } else if (c == '-') {
         a[x] = a[y] - a[z];
      } else if (c == '*') {
         a[x] = a[y] * a[z];
      } else if (c == '/') {
         a[x] = a[y] / a[z];
      }
   }

   for (int i = 0; i < n; ++i) {
      std::cout << a[i] << " ";
   }
}
