#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int s[2][M];
  int ans[N];
  for (int i = 0; i < N; i++) ans[i] = 0;
  ans[0] = 1;
  int flag = 0;
  for (int i = 0; i < M; i++) {
    cin >> s[0][i] >> s[1][i];
    if (s[0][i] != 1) {
      if (ans[s[0][i] - 1] == 0)
        ans[s[0][i] - 1] = s[1][i];
      else {
        if (ans[s[0][i] - 1] != s[1][i]) flag = -1;
      }
    } else {
      if (ans[s[0][i] - 1] == 1)
        ans[s[0][i] - 1] = s[1][i];
      else {
        if (ans[s[0][i] - 1] != s[1][i]) flag = -1;
      }
    }
    if (s[0][i] == 1 && s[1][i] == 0) flag = -1;
  }
  if (flag == -1)
    cout << -1 << endl;
  else {
    for (int i = 0; i < N; i++) cout << ans[i];
  }
}
