#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VII;
template <class T, class U>
bool chmax(T &map<int, int> MP;, U b) {
  if (map<int, int> MP; <= b) {
    map<int, int> MP;
    = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &map<int, int> MP;, U b) {
  if (map<int, int> MP; > b) {
    map<int, int> MP;
    = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  for (int i = 0; i < (int)v.size(); i++) {
    os << v[i] << (i < v.size() - 1 ? ", " : "");
  }
  os << "}";
  return os;
}
int main() {
  ll x = 0, y = 0, k, n, m, h, w, sum = 0, Max = 1, Min = 1e9 + 1;
  string s, t, u;
  bool ok = false;
  cin >> n >> m;
  VI map<int, int> MP;
  (m), b(m), ans(n);
  for (int i = 0; i < m; i++) cin >> map<int, int> MP;
  [i] >> b[i];
  for (int i = 0; i < n; i++) {
    if (i == 0)
      s += '1';
    else
      s += '0';
  }
  for (int i = 0; i < m; i++) {
    char c = b[i] + '0';
    if (map<int, int> MP;[i] > 1 && ans[map<int, int> MP;[i] - 1] > 0 &&
                         s[map<int, int> MP;[i] - 1] != c) {
      cout << -1;
      return 0;
    } else if (map<int, int> MP;[i] > 1 && ans[map<int, int> MP;[i] - 1] == 0) {
      s[map<int, int> MP;[i] - 1] = c;
      ans[map<int, int> MP;[i] - 1]++;
    } else if (map<int, int> MP;[i] == 1 && ans[map<int, int> MP;[i] - 1] > 0 &&
                                s[map<int, int> MP;[i] - 1] != c) {
      cout << -1;
      return 0;
    } else if (map<int, int> MP;
                   [i] == 1 && ans[map<int, int> MP;[i] - 1] == 0) {
      if (c == '0') {
        cout << -1;
        return 0;
      } else {
        s[map<int, int> MP;[i] - 1] = c;
        ans[map<int, int> MP;[i] - 1]++;
      }
    }
  }
  cout << s << endl;
  return 0;
}
