function clauses = BR_rand_clauses(n,m,k)
%

clauses = zeros(m,k);

done = 0;
count = 0;
while done==0
    samp = randperm(n);
    samp = samp(1:k);
    s = rand(1,k)<0.5;
    s = 2*s - 1;
    samp = samp.*s;
    if max(min((samp==clauses)'))==0
        count = count + 1;
        clauses(count,:) = samp;
        if count==m
            done = 1;
        end
    end
end

for c = 1:m
    for d = 1:k
        v = clauses(c,d) - 1;
        if v>=n
            f = rem(v,n) + 1;
            clauses(c,d) = -f;
        end
    end
end
