#include <bits/stdc++.h>
using namespace std;
long long int binpow(long long int, long long int);
void dfs(vector<vector<long long int> > &, long long int,
         vector<long long int> &);
void bfs(vector<vector<long long int> > &, long long int,
         vector<long long int> &);
void solve() {
  long long int n, m;
  cin >> n >> m;
  long long int a[3];
  memset(a, 0, sizeof(a));
  ;
  map<long long int, long long int> m1;
  vector<pair<long long int, long long int> > p;
  for (long long int i = 0; i < m; i++) {
    long long int a, b;
    cin >> a >> b;
    m1[a] = b;
    p.push_back(make_pair(a, b));
  }
  long long int found = 0;
  for (long long int i = 0; i < p.size(); i++) {
    if ((m1[p[i].first] != p[i].second) ||
        (p[i].first == 1 && p[i].second == 0) || (p[i].first > n)) {
      found = 1;
      break;
    }
  }
  if (found == 1) {
    cout << "-1"
         << "\n";
    return;
  }
  for (long long int i = 0; i < p.size(); i++) {
    a[p[i].first - 1] = p[i].second;
  }
  if (n == 1 && m1[1] == 0) {
    cout << "0"
         << "\n";
    return;
  }
  if (a[0] == 0) {
    a[0] = 1;
  }
  for (long long int i = 0; i < n; i++) {
    cout << a[i];
  }
  cout << "\n";
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
long long int binpow(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
void dfs(vector<vector<long long int> > &v, long long int x,
         vector<long long int> &vis) {
  vis[x] = 1;
  for (long long int i = 0; i < v[x].size(); i++) {
    if (vis[v[x][i]] == 0) {
      dfs(v, v[x][i], vis);
    }
  }
}
void bfs(vector<vector<long long int> > &v, long long int x,
         vector<long long int> &vis) {
  queue<long long int> q;
  q.push(x);
  while (!q.empty()) {
    long long int p = q.front();
    q.pop();
    for (long long int i = 0; i < v[p].size(); i++) {
      if (vis[v[p][i]] == 0) {
        vis[v[p][i]] = 1;
        q.push(v[p][i]);
      }
    }
  }
}
