#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)998244353;
const long long maxn = (long long)2e5 + 5;
const int nnn = 1048590;
const int inf = numeric_limits<int>::max() - 1;
const long long INF = 1e18;
long long dx[] = {0, 1, 0, -1};
long long dy[] = {1, 0, -1, 0};
long long dxx[] = {0, 1, 0, -1, 1, 1, -1, -1};
long long dyy[] = {1, 0, -1, 0, 1, -1, 1, -1};
void solve() {
  long long a[5];
  memset(a, -1, sizeof(a));
  long long n, m, pos, c;
  cin >> n >> m;
  while (m--) {
    cin >> pos >> c;
    if (a[pos] != -1 && a[pos] != c) {
      cout << "-1";
      return;
    }
    if (pos == 1 && c == 0) {
      cout << "-1";
      return;
    }
    if (pos > n) {
      cout << "-1";
      return;
    }
    a[pos] = c;
  }
  for (int i = 1; i <= (n); i++) cout << (a[i] == -1 ? (long long)1 : a[i]);
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long T;
  T = 1;
  long long CT = 0;
  while (T--) {
    solve();
  }
  return 0;
}
