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