def transfer(i, k):
    now = where[i]
    while infants[now]:
        (r, j) = heappop(infants[now])
        if ((where[j] != now) or (j == i)):
            continue
        if (highest_rate[now] != (- r)):
            highest_rate[now] = (- r)
            heappush(queue, ((- r), now, j))
        heappush(infants[now], (r, j))
        break
    else:
        highest_rate[now] = None
    entry(i, k)
def transfer(i, k):
    now = where[i]
    while infants[now]:
        (r, j) = heappop(infants[now])
        if ((where[j] != now) or (j == i)):
            continue
        if (highest_rate[now] != (- r)):
            highest_rate[now] = (- r)
            heappush(queue, ((- r), now, j))
        heappush(infants[now], (r, j))
        break
    else:
        highest_rate[now] = None
    entry(i, k)