Problem:
Score : 700 points

Problem Statement

For strings s and t, we will say that s and t are prefix-free when neither is a prefix of the other.

Let L be a positive integer. A set of strings S is a good string set when the following conditions hold true:

Each string in S has a length between 1 and L (inclusive) and consists of the characters 0 and 1.

Any two distinct strings in S are prefix-free.

We have a good string set S = \{ s_1, s_2, ..., s_N \}. Alice and Bob will play a game against each other. They will alternately perform the following operation, starting from Alice:

Add a new string to S. After addition, S must still be a good string set.

The first player who becomes unable to perform the operation loses the game. Determine the winner of the game when both players play optimally.

Constraints

1 \leq N \leq 10^5

1 \leq L \leq 10^{18}

s_1, s_2, ..., s_N are all distinct.

{ s_1, s_2, ..., s_N } is a good string set.

|s_1| + |s_2| + ... + |s_N| \leq 10^5

Input

Input is given from Standard Input in the following format:

N L
s_1
s_2
:
s_N

Output

If Alice will win, print Alice; if Bob will win, print Bob.

Sample Input 1

2 2
00
01

Sample Output 1

Alice

If Alice adds 1, Bob will be unable to add a new string.

Sample Input 2

2 2
00
11

Sample Output 2

Bob

There are two strings that Alice can add on the first turn: 01 and 10.
In case she adds 01, if Bob add 10, she will be unable to add a new string.
Also, in case she adds 10, if Bob add 01, she will be unable to add a new string.

Sample Input 3

3 3
0
10
110

Sample Output 3

Alice

If Alice adds 111, Bob will be unable to add a new string.

Sample Input 4

2 1
0
1

Sample Output 4

Bob

Alice is unable to add a new string on the first turn.

Sample Input 5

1 2
11

Sample Output 5

Alice

Sample Input 6

2 3
101
11

Sample Output 6

Bob

Solution in Common Lisp (SBCL 1.1.14) (judge verdict: Runtime Error)

;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload '(:cl-debug-print :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
;;;
;;; Trie
;;;

;; ASCII code:
;; #\A: 65
;; #\a: 97
;; #\0: 48
(declaim (inline trie-char-encode))
(defun trie-char-encode (x)
  (if (char= #\0 x) 0 1))

(defconstant +trie-alphabet-size+ 2)

;; TODO: enable to set VALUE to NIL by distinguishing null and unbound.
(declaim (inline %make-trie-node))
(defstruct (trie-node (:constructor %make-trie-node
                          (&optional value
                           &aux (children (make-array #.+trie-alphabet-size+
                                                      :element-type t
                                                      :initial-element 0)))))
  (value nil)
  (children nil :type (simple-array t (#.+trie-alphabet-size+))))

(declaim (inline make-trie))
(defun make-trie () (%make-trie-node))

(declaim (inline trie-add!))
(defun trie-add! (trie-node string &optional (value t))
  "Adds STRING to the trie and assigns VALUE to it. Note that null value means
the string doesn't exist in the trie: that is, (trie-add! <trie-node> <string>
nil) virtually works as a deletion of <string>."
  (declare (vector string))
  (let ((end (length string)))
    (labels ((recur (node position)
               (if (= position end)
                   (unless (trie-node-value node)
                     (setf (trie-node-value node) value))
                   (let ((children (trie-node-children node))
                         (char (trie-char-encode (aref string position))))
                     (when (eql 0 (aref children char))
                       (setf (aref children char) (%make-trie-node)))
                     (recur (aref children char) (+ 1 position))))))
      (recur trie-node 0)
      trie-node)))

(declaim (inline trie-query))
(defun trie-query (trie-node string function &key (start 0) end)
  "Calls FUNCTION for each prefix of STRING existing in TRIE-NODE. FUNCTION
takes two arguments: the end position and the assigned value."
  (declare (vector string)
           ((integer 0 #.most-positive-fixnum) start)
           ((or null (integer 0 #.most-positive-fixnum)) end)
           (function function))
  (let ((end (or end (length string))))
    (labels ((recur (node position)
               (when (trie-node-value node)
                 (funcall function position (trie-node-value node)))
               (unless (= position end)
                 (let ((children (trie-node-children node))
                       (char (trie-char-encode (aref string position))))
                   (unless (eql 0 (aref children char))
                     (recur (aref children char) (+ 1 position)))))))
      (recur trie-node start))))

(defun trie-get (trie-node string &key (start 0) end)
  "Finds STRING in TRIE-NODE and returns the assigned value if it exists,
  otherwise NIL."
  (declare (vector string)
           ((integer 0 #.most-positive-fixnum) start)
           ((or null (integer 0 #.most-positive-fixnum)) end))
  (let ((end (or end (length string))))
    (labels ((recur (node position)
               (if (= position end)
                   (trie-node-value node)
                   (let ((children (trie-node-children node))
                         (char (trie-char-encode (aref string position))))
                     (unless (eql 0 (aref children char))
                       (recur (aref children char) (+ 1 position)))))))
      (recur trie-node start))))

(defun trie-query-longest (trie-node string &key (start 0) end)
  "Returns the end position and the value of the longest word in TRIE-NODE which
coincides with a prefix of STRING. Returns NIL when no such words exist."
  (declare (vector string)
           ((integer 0 #.most-positive-fixnum) start)
           ((or null (integer 0 #.most-positive-fixnum)) end))
  (let ((end (or end (length string)))
        result-position
        result-value)
    (declare ((or null (integer 0 #.most-positive-fixnum)) result-position))
    (labels ((recur (node position)
               (when (trie-node-value node)
                 (setq result-position position
                       result-value (trie-node-value node)))
               (unless (= position end)
                 (let ((children (trie-node-children node))
                       (char (trie-char-encode (aref string position))))
                   (unless (eql 0 (aref children char))
                     (recur (aref children char) (+ 1 position)))))))
      (recur trie-node start)
      (values result-position result-value))))


(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun mex (&rest args)
  (let ((table (make-hash-table :test #'eq)))
    (dolist (x args)
      (setf (gethash x table) t))
    (loop for x of-type (integer 0 #.most-positive-fixnum) from 0
          unless (gethash x table)
          do (return x))))

(defun test (depth)
  (let ((seq (make-array (+ 1 depth) :element-type 'uint32)))
    (setf (aref seq depth) 0)
    (loop for d from (- depth 1) downto 0
          do (setf (aref seq d)
                   (apply #'mex
                          (cons 0
                                (loop for end from (+ d 2) to depth
                                      collect
                                         (loop with xor = 0
                                               for i from (+ d 1) below end
                                               do (setf xor (logxor xor (aref seq i)))
                                               finally (return xor)))))))
    seq))

(declaim (inline grundy))
(defun grundy (depth max-depth)
  (assert (<= 0 depth max-depth))
  (if (= depth max-depth)
      0
      (let ((x (- max-depth depth))
            (res 1))
        (declare (uint62 x res))
        (loop while (evenp x)
              do (setf res (* res 2))
                 (setf x (floor x 2)))
        res)))

(defun main ()
  (let* ((n (read))
         (l (read))
         (trie (make-trie))
         (grundys (test l))
         (res 0))
    (declare (uint62 n l res))
    (dotimes (i n)
      (trie-add! trie (the simple-string (read-line))))
    #>grundys
    (labels ((dfs (node depth)
               (declare (uint62 depth))
               (if (eql 0 node)
                   (setq res (logxor res (grundy (- depth 1) l)))
                   (let ((children (trie-node-children node)))
                     (dfs (aref children 0) (+ depth 1))
                     (dfs (aref children 1) (+ depth 1))))))
      (dfs trie 0)
      (if (zerop res)
          (write-line "Bob")
          (write-line "Alice")))))

#-swank (main)