#include <bits/stdc++.h>
template <class T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<char> ans(n, 'x');
  for (int(i) = 0; (i) < (m); (i)++) {
    int s;
    char c;
    cin >> s >> c;
    s--;
    if (ans[s] != 'x' && ans[s] != c) {
      cout << -1 << endl;
      return 0;
    }
    if (s == 0 && c == '0') {
      cout << -1 << endl;
      return 0;
    }
    ans[s] = c;
  }
  for (int(i) = 0; (i) < (n); (i)++) {
    if (ans[i] == 'x') {
      if (!i)
        ans[i] = '1';
      else
        ans[i] = '0';
    }
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
