#include <bits/stdc++.h>
using namespace std;
inline string GetString() {
  char GS[1000005];
  scanf("%s", GS);
  string ret = GS;
  return ret;
}
inline char getc() {
  char c = ' ';
  while (c == ' ' || c == '\t' || c == '\r' || c == '\n') c = getchar();
  return c;
}
string s;
vector<int> adj[10005];
vector<int> daftar;
int hasil[10005];
int i, j;
int main() {
  s = GetString();
  i = 2;
  int numnow = 0;
  while (s[i] != ')') {
    if (s[i] == '_') {
      ++numnow;
    } else {
      if (numnow != 0) daftar.push_back(numnow);
      numnow = 0;
    }
    ++i;
  }
  if (numnow != 0) daftar.push_back(numnow);
  i++;
  i++;
  while (s[i] != '.') {
    ++i;
    int num1 = 0;
    int num2 = 0;
    char typ;
    while (s[i] == '_') {
      ++i;
      ++num1;
    }
    typ = s[i];
    ++i;
    while (s[i] == '_') {
      ++i;
      ++num2;
    }
    if (typ == '>') {
      adj[num1].push_back(num2);
    } else {
      adj[num2].push_back(num1);
    }
  }
  memset(hasil, -1, sizeof(hasil));
  bool finish;
  while (true) {
    bool update = false;
    for (i = 0; i < (int)(daftar).size(); ++i) {
      if (hasil[daftar[i]] == -1) {
        int maxi = -1;
        for (j = 0; j < (int)(adj[daftar[i]]).size(); ++j) {
          if (hasil[adj[daftar[i]][j]] < 0)
            maxi = 1000000;
          else
            maxi = max(maxi, hasil[adj[daftar[i]][j]]);
        }
        if (maxi < 1000000) {
          hasil[daftar[i]] = maxi + 1;
          update = true;
          break;
        }
      }
    }
    finish = true;
    for (i = 0; i < (int)(daftar).size(); ++i)
      if (hasil[daftar[i]] == -1) finish = false;
    if (finish) break;
    if (!update) break;
  }
  bool valid = finish;
  for (i = 0; i < (int)(daftar).size(); ++i)
    if (hasil[daftar[i]] < 0 || hasil[daftar[i]] > 9) valid = false;
  if (!valid)
    printf("false\n");
  else {
    for (i = 0; i < (int)(daftar).size(); ++i) printf("%d", hasil[daftar[i]]);
    printf("\n");
  }
}
