#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 < m; i++) {
    cin >> s.at(i) >> c.at(i);
  }
  string ans;
  if (n == 3)
    ans = "100";
  else if (n == 2)
    ans = "10";
  else if (n == 1)
    ans = "1";
  for (int i = 0; i < m; i++) {
    ans.at(s.at(i) - 1) = c.at(i);
  }
  for (int i = 0; i < m; i++) {
    if (n >= 2 && s.at(i) == 1 && c.at(i) == '0') {
      ans = "-1";
    }
  }
  for (int i = 1; i < m; i++) {
    for (int j = 0; j < i; j++) {
      if (s.at(i) == s.at(j) && c.at(i) != c.at(j)) {
        ans = "-1";
      }
    }
  }
  cout << ans << endl;
}
