#include <bits/stdc++.h>
using namespace std;
vector<long long int> v[300011], vv[300011];
map<pair<long long int, long long int>, long long int> mp, mp1;
bool visited[300001];
void chichi() {
  for (long long int i = 0; i < 300011; i++) visited[i] = 0;
}
long long int a[300011][2];
long long int ans = 0;
void dfs1(long long int s) {
  ans++;
  visited[s] = 1;
  vector<long long int>::iterator it;
  for (it = v[s].begin(); it != v[s].end(); it++) {
    if (!visited[(*it)]) {
      dfs1((*it));
    }
  }
}
void dfs2(long long int s) {
  ans++;
  visited[s] = 1;
  vector<long long int>::iterator it;
  for (it = vv[s].begin(); it != vv[s].end(); it++) {
    if (!visited[(*it)]) {
      dfs2((*it));
    }
  }
}
void dfsmin(long long int s) {
  visited[s] = 1;
  for (long long int i = 0; i < v[s].size(); i++) {
    if (!visited[v[s][i]]) {
      if (mp[make_pair(s, v[s][i])]) {
        mp[make_pair(s, v[s][i])] = 2;
      } else if (mp[make_pair(v[s][i], s)]) {
        mp[make_pair(v[s][i], s)] = 3;
      }
      if (mp1[make_pair(s, v[s][i])]) {
        dfsmin(v[s][i]);
      }
    }
  }
}
void dfsmax(long long int s) {
  visited[s] = 1;
  for (long long int i = 0; i < v[s].size(); i++) {
    if (!visited[v[s][i]]) {
      if (mp[make_pair(s, v[s][i])]) {
        mp[make_pair(s, v[s][i])] = 3;
      } else if (mp[make_pair(v[s][i], s)]) {
        mp[make_pair(v[s][i], s)] = 2;
      }
      dfsmax(v[s][i]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, i, j, k, l, r, q, x, n, m, s;
  cin >> n >> m >> s;
  k = 0;
  for (i = 0; i < m; i++) {
    cin >> l;
    if (l == 1) {
      cin >> l >> r;
      v[l].push_back(r);
      vv[l].push_back(r);
      mp1[make_pair(l, r)]++;
    } else {
      cin >> l >> r;
      a[k][0] = l;
      a[k][1] = r;
      k++;
      v[l].push_back(r);
      v[r].push_back(l);
      mp[make_pair(l, r)]++;
    }
  }
  dfs1(s);
  cout << ans << "\n";
  ans = 0;
  chichi();
  dfsmax(s);
  chichi();
  for (i = 0; i < k; i++) {
    if (mp[make_pair(a[i][0], a[i][1])] == 3)
      cout << "+";
    else
      cout << "-";
    mp[make_pair(a[i][0], a[i][1])] = 1;
  }
  dfs2(s);
  cout << "\n";
  cout << ans << "\n";
  chichi();
  dfsmin(s);
  for (i = 0; i < k; i++) {
    if (mp[make_pair(a[i][0], a[i][1])] == 2)
      cout << "-";
    else
      cout << "+";
  }
  return 0;
}
