from typing import Tuple
from typing import Optional
from typing import List
import string
import random


def random2Dcharacters(
    shape: Tuple[int, int], samples: Optional[List[str]] = None
) -> List[List[str]]:
    """A random 2D characters array is generated.

    Args:
        shape: (m, n) shape of the characters array.
        samples: cumstomized letters for sampling. e.g., ['a', 'b'].
    """
    m, n = shape
    letters = string.ascii_lowercase
    if samples:
        letters = samples
    return [[random.choice(letters) for i in range(n)] for _ in range(m)]