#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> arr(n + 1, -1);
  while (m--) {
    int s, c;
    cin >> s >> c;
    if (arr[s] == -1)
      arr[s] = c;
    else
      return cout << -1, 0;
  }
  if (arr[1] == 0) return cout << -1, 0;
  for (int i = 1; i <= n; i++) {
    cout << arr[i];
  }
}
