#include <bits/stdc++.h>
using namespace std;
const double h = 1e-6;
const int MAX_ = 100005;
inline long long int mul(long long int a, long long int b) {
  return (a * 1ll * b) % 1000000007;
}
inline long long int sub(long long int a, long long int b) {
  long long int c = a - b;
  if (c < 0) c += 1000000007;
  return c;
}
inline long long int add(long long int a, long long int b) {
  long long int c = a + b;
  if (c > 1000000007) c -= 1000000007;
  return c;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  int arr[n + 1];
  memset(arr, -1, sizeof(arr));
  int f = 0;
  while (m--) {
    int a, b;
    cin >> a >> b;
    if (arr[a] == -1 || arr[a] == b) {
      arr[a] = b;
    } else {
      f = 1;
      break;
    }
  }
  if (f)
    cout << -1;
  else {
    for (int i = 1; i <= n; i++) {
      if (arr[i] == 0) {
        f = 1;
        break;
      } else {
        break;
      }
    }
    if (f)
      cout << -1;
    else {
      int t = 1;
      for (int i = 1; i <= n; i++) {
        if (arr[i] == -1) {
          arr[i] = t;
        } else {
          t = 0;
        }
      }
      for (int i = 1; i <= n; i++) cout << arr[i];
    }
  }
  return 0;
}
