#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  if (M > 0) {
    vector<pair<int, int>> sc(M);
    for (int i = 0; i < M; ++i) {
      cin >> sc[i].first >> sc[i].second;
    }
    vector<pair<int, bool>> number(N);
    for (int i = 0; i < N; ++i) {
      number[i].first = 0;
      number[i].second = true;
    }
    for (int i = 0; i < M; ++i) {
      if (number[sc[i].first - 1].second == true) {
        number[sc[i].first - 1].first = sc[i].second;
        number[sc[i].first - 1].second = false;
      } else if (number[sc[i].first - 1].first == sc[i].second) {
      } else {
        cout << "-1" << endl;
        return 0;
      }
    }
    if (number[0].first == 0 && N > 1) {
      cout << "-1" << endl;
      return 0;
    }
    for (int i = 0; i < N; ++i) {
      cout << number[i].first;
    }
  } else {
    for (int i = 0; i < N; ++i) {
      cout << 1;
    }
  }
  cout << endl;
  return 0;
}
