def flip(res):
    """flips 'x', 'o' or 'draw'."""
    if res == 'x':
        return 'o'
    elif res == 'o':
        return 'x'
    elif res == 'draw':
        return 'draw'
    else:
        raise RuntimeError("Invalid res: %s" % str(res))