#include <bits/stdc++.h>
using namespace std;
const long long int N = 300009;
const long long int mod = 1000000007;
void pre() {}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin.exceptions(cin.failbit);
  ;
  pre();
  long long int n, m;
  long long int s, c;
  cin >> n >> m;
  if (n == 1) {
    if (m == 1) {
      cin >> s >> c;
      cout << c;
      return 0;
    } else {
      cout << 0 << "\n";
      return 0;
    }
  }
  string st = "";
  for (long long int i = 0; i < (n); ++i) st += '#';
  for (long long int i = 0; i < (m); ++i) {
    cin >> s >> c;
    if (st[s - 1] != '#' && (st[s - 1] != (c + '0'))) {
      cout << -1 << "\n";
      return 0;
    }
    st[s - 1] = (c + '0');
  }
  if (st[0] == '0') {
    cout << -1 << "\n";
    return 0;
  }
  if (st[0] == '#') {
    st[0] = '1';
  }
  for (long long int i = 1; i < (n); ++i)
    if (st[i] == '#') st[i] = '0';
  cout << st << "\n";
  return 0;
}
