#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int ans[1223];
int vis[1223];
int q[123][2];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  bool imp = false;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (vis[x] and ans[x] != y) imp = true;
    vis[x] = 1;
    ans[x] = y;
  }
  if (vis[1] == 0) ans[1] = 1;
  if (imp or ans[1] == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) cout << ans[i];
  return 0;
}
