#include <bits/stdc++.h>
using namespace std;
int n, m;
int a, b;
int arr[10];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  memset(arr, -1, sizeof(arr));
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    if (a == 1 && b == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (arr[a] == -1) {
      arr[a] = b;
    } else {
      if (arr[a] != b) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (arr[i] == -1) {
      if (i == 1)
        cout << 1;
      else
        cout << 0;
    } else
      cout << arr[i];
  }
  cout << endl;
}
