#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int arr[n + 2];
  for (int i = 1; i <= n; i++) arr[i] = -1;
  int flag = 0;
  for (int i = 1; i <= m; i++) {
    long long int a, b;
    cin >> a >> b;
    if (arr[a] == -1)
      arr[a] = b;
    else if (arr[a] == b)
      arr[a] = b;
    else
      flag = 1;
  }
  if (arr[1] == 0 && n != 1) flag = 1;
  if (arr[1] == 0 && n == 1) {
    cout << 0 << '\n';
    return 0;
  }
  if (flag) {
    cout << -1 << '\n';
    return 0;
  }
  if (arr[1] == -1) arr[1] = 1;
  for (int i = 1; i <= n; i++)
    if (arr[i] == -1) arr[i] = 0;
  for (int i = 1; i <= n; i++) cout << arr[i];
}
