#include <bits/stdc++.h>
using namespace std;
int n, m;
int di, val;
int ans[10];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  int dim[10];
  for (int i = 0; i < 10; i++) dim[i] = -1, ans[i] = -1;
  int ga = 0;
  for (int i = 0; i < m; i++) {
    cin >> di >> val;
    if (dim[di] != val && dim[di] != -1) ga = 1;
    dim[di] = val;
    ans[di] = val;
  }
  if (ga || !ans[1]) {
    cout << "-1\n";
    return 0;
  }
  for (int i = 2; i <= n; i++)
    if (ans[i] == -1) ans[i] = 0;
  if (ans[1] == -1 && n > 1)
    ans[1] = 1;
  else if (ans[1] == -1)
    ans[1] = 0;
  for (int i = 1; i <= n; i++) cout << ans[i];
  cout << "\n";
  return 0;
}
