#include <bits/stdc++.h>
using namespace std;
template <typename TYPE>
inline TYPE sqr(const TYPE& a) {
  return (a) * (a);
}
const int INF = 1000 * 1000 * 1000;
const long double EPS = 1e-9;
const long double PI = 2 * acos(0.0);
const int N = 100100;
int top;
int j;
int a[N];
string ans;
bool f() {
  if (j >= top) return false;
  if (a[j] == 0) {
    ++j;
    ans.append("int");
    return true;
  }
  ++j;
  ans.append("pair<");
  if (!f()) return false;
  ans.append(",");
  if (!f()) return false;
  ans.append(">");
  return true;
}
int main() {
  int n;
  scanf("%d\n", &n);
  string s;
  getline(cin, s);
  for (int i = 0; i < int(s.size()); ++i)
    if (s[i] == 't')
      a[top++] = 0;
    else if (s[i] == 'p')
      a[top++] = 1;
  if (!f() || j < top) {
    puts("Error occurred");
  } else {
    puts(ans.c_str());
  }
  return 0;
}
