from typing import List
import random


def random_matrix(a:int,b:int) -> List[List[int]]:
    """
    Generate a random boolean matrix, each row and each column contains 1 somewhere.

    Parameters
    ----------
    a : number of rows.
    b : number of columns.

    Returns
    -------
    m : a random matrix of size axb
    """
    br=list(range(b))
    random.shuffle(br)
    # empty matrix
    mm = [[0 for _ in range(b)] for _ in range(a)]
    # for each row
    for i in range(a):
        mm[i][br[i]]=1
    # for each column
    for j in range(b):
        mm[random.randrange(a)][j]=1
    return mm