#include <bits/stdc++.h>
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  int n, m, arr[4] = {-1, -1, -1, -1};
  std::cin >> n >> m;
  bool good = true;
  for (int i = 0; i < m; ++i) {
    int pos, val;
    std::cin >> pos >> val;
    if (arr[pos] != -1 && arr[pos] != val) {
      good = false;
      break;
    }
    arr[pos] = val;
  }
  if (arr[1] == 0) {
    good = false;
  } else if (arr[1] == -1) {
    arr[1] = 1;
  }
  if (arr[2] == -1) arr[2] = 0;
  if (arr[3] == -1) arr[3] = 0;
  if (good) {
    for (int i = 1; i <= n; ++i) {
      std::cout << arr[i];
    }
    std::cout << '\n';
  } else {
    std::cout << "-1\n";
  }
  return 0;
}
