class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

d = A("d")
c = B("c")
n = B("n")
i = A("i")
b = B("b")
j = B("j")
l = A("l")
h = B("h")

d.r = i
c.t = j
n.t = b
i.r = d
b.t = j
j.t = n
l.r = i
h.t = c
assert c.t.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

d = A("d")
c = B("c")
n = B("n")
i = A("i")
b = B("b")
j = B("j")
l = A("l")
h = B("h")

d.r = i
c.t = j
n.t = b
i.r = d
b.t = j
j.t = n
l.r = i
h.t = c
assert c.t.t.t.t.t.t.t.txt == "j"