import random


def random_ksat(k, num_vars, num_clauses, seed=None):
    """Generates a random kSAT problem following the format of this module"""
    random.seed(seed)
    var_list = list(range(1, num_vars + 1))
    clauses = [random.sample(var_list, k) for _ in range(num_clauses)]
    for i in range(num_clauses):
        for j in range(k):
            clauses[i][j] *= random.choice([1, -1])
    return clauses