#include <bits/stdc++.h>
using namespace std;
long long ans, mx, sum, mn = 1e8, cnt;
long long a[3];
int main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long c, b;
    cin >> c >> b;
    c--;
    if (c == 0)
      a[0] = b;
    else if (c == 1)
      a[1] = b;
    else if (c == 2)
      a[2] = b;
  }
  if (a[0] == 0 && n != 1)
    cout << -1;
  else {
    for (long long i = 0; i < n; i++) {
      cout << a[i];
    }
  }
}
