def writegive(giveup, g):
    """Write giveup data."""
    try:
        outfile = open(giveup, 'w')
    except Exception:
        print('Unable to write a file:', giveup)
        return
    for i in range(3):
        for j in g[i]:
            outfile.write(j.strip() + '\n')
    for i in g[3]:
        outfile.write('g ' + str(i[0]) + ' ' + i[1] + '\n')
    outfile.close
    return
