#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, si;
  char ci;
  string ans;
  cin >> n >> m;
  ans.assign(n + 1, 'a');
  ans[n] = '\0';
  int flag = 0;
  while (m--) {
    cin >> si >> ci;
    si--;
    if ((si == 0) && (ci == '0') || (ans[si] != ci) && (ans[si] != 'a'))
      flag = 1;
    ans[si] = ci;
  }
  if (!flag)
    if ((n == 1) && (ans[0] == 'a'))
      ans = "0";
    else {
      if (ans[0] == 'a') ans[0] = '1';
      for (int i = 1; i < n; i++) {
        if (ans[i] == 'a') ans[i] = '0';
      }
    }
  else
    ans = "-1";
  cout << ans << '\n';
  return 0;
}
