#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s;
  vector<char> c;
  s.resize(m);
  c.resize(m);
  for (int i = 0; i < (int)(m); i++) cin >> s[i] >> c[i];
  string str;
  str.resize(m, '0');
  for (int i = 0; i < (int)(m); i++) str[s[i] - 1] = c[i];
  for (int i = 0; i < (int)(m); i++)
    for (int j = 0; j < (int)(m); j++)
      if ((s[i] == s[j]) && (c[i] == c[j])) str = "-1";
  if (s[0] == 1 && c[0] == '0') str = "-1";
  if (str[0] == '0') str[0] == '1';
  cout << str << endl;
  return 0;
}
