#include <bits/stdc++.h>
using namespace std;
const int MAX = 10;
int arr[MAX];
int n, m;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  memset(arr, -1, sizeof(arr));
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    if (arr[x] != -1 && arr[x] != y) return cout << -1 << "\n", 0;
    arr[x] = y;
  }
  if (arr[1] == 0 && n != 1) return cout << -1 << "\n", 0;
  for (int i = 1; i <= n; ++i) {
    if (arr[i] == -1) arr[i] = 0;
    if (arr[i] == 0 && i == 1) arr[i] = 1;
    cout << arr[i];
  }
  cout << "\n";
  return 0;
}
