def find_root(cfg):
    """
    Find a root node for the given cfg
    """
    toVisit = set()
    for adj in cfg['adjacency']:
        for n in adj:
            toVisit.add(n['id'])
    for i in range(len(cfg['nodes'])):
        if cfg['nodes'][i]['id'] not in toVisit:
            return i
    return 0