#include <bits/stdc++.h>
using namespace std;
const int NN = 1e6 + 7;
const int N = 2e5 + 7;
const int M = 20;
const int mod = 998244353;
const long long inf = 1e18 + 7;
const double long rf = 1e-14;
void solve1() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n + 1);
  vector<int> ans(n + 1, -1);
  vector<pair<int, int> > g;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    g.push_back({x, y});
    if ((ans[x] != -1 && ans[x] != y) || (x == 1 && y == 0 && n != 1)) {
      cout << "-1";
      return;
    }
    ans[x] = y;
  }
  string res = "";
  for (int i = 1; i <= n; i++) {
    if (ans[i] == -1) ans[i] = 0;
    res += (char)(ans[i] + '0');
  }
  if ((int)res.size() > 1 && res[0] == '1') res[0] = '1';
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
  int cghf = 1;
  while (cghf--) {
    solve1();
  }
}
