#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<char> ans(n);
  vector<bool> cha(n, false);
  for (int i = 0; i < m; i++) {
    int id;
    char c;
    cin >> id >> c;
    id--;
    if (cha[id]) {
      if (ans[id] != c) {
        cout << -1 << endl;
        return 0;
      }
    } else {
      ans[id] = c;
      cha[id] = true;
    }
  }
  for (int i = 0; i < n; i++)
    if (!cha[i]) {
      if (i == 0)
        ans[i] = '1';
      else
        ans[i] = '0';
    }
  if (ans[0] == '0')
    cout << -1 << endl;
  else
    for (auto c : ans) cout << c;
  cout << endl;
  return 0;
}
