#include <bits/stdc++.h>
using namespace std;
int ans[100010];
void solve() {
  string s;
  cin >> s;
  int n = s.length(), x = 0, y = 0, lst = -1;
  for (int i = 0; i < n; i++) {
    if (s[i] == '(')
      x++;
    else
      x--;
    if (x < 0) {
      cout << "-1\n";
      return;
    }
    if (s[i] == '#') lst = i;
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == '(')
      y++;
    else
      y--;
    if (i == lst) {
      y -= x;
    }
    if (y < 0) {
      cout << "-1\n";
      return;
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == '#') {
      if (i == lst) {
        printf("%d\n", x + 1);
      } else
        cout << "1\n";
    }
  }
}
int main() {
  int t = 1;
  scanf("%d", &t);
  while (t--) {
    solve();
  }
}
