def write_pq_list(pq_list, max_index, max_value, factor1, factor2, filename):
    """Write p,q-list to file"""
    if pq_list:
        with open(filename, 'w') as f:
            print('#max index', 'max value', 'factor1', 'factor2', sep='\t',
                file=f)
            print('#' + str(max_index), str(max_value), str(factor1), str(
                factor2), sep='\t', file=f)
            for p, q in pq_list:
                print(p, q, file=f)
