#include <bits/stdc++.h>
using namespace std;
const int inf = 1001001001;
const int mod = 1000000007;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> s(m);
  vector<char> c(m);
  for (int i = 0; i < (m); ++i) cin >> s[i] >> c[i];
  vector<char> ans(n, '?');
  bool elf = true;
  for (int i = 0; i < (m); ++i) {
    s[i]--;
    if (ans[s[i]] == '?') {
      ans[s[i]] = c[i];
    } else {
      if (ans[s[i]] != c[i]) elf = false;
    }
  }
  for (int i = 0; i < (n); ++i) {
    if (ans[i] == '?') ans[i] = '0';
  }
  if ((!elf || count((ans).begin(), (ans).end(), '0')) == n) {
    puts("-1");
    return 0;
  }
  if (ans[0] == 0) ans[0] = '1';
  for (int i = 0; i < (n); ++i) cout << ans[i];
  cout << endl;
  return 0;
}
