N, K = gets.split.map(&:to_i) def f 0.upto(2 ** N - 1) do |mask| str = mask.to_s(2).rjust(N, '0') ok = true found = false N.downto(K) do |k| 0.upto(N - k) do |i| s = str[i...i + k] if s == s.reverse if k > K ok = false else found = true end end end end return str if ok && found end false end if N <= 9 if res = f puts res else puts -1 end elsif K <= 3 puts -1 else tmp = '010011' len = 6 str = ('1' * K) + tmp * Rational(N, len).ceil puts str[0...N] end