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

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

n = A("n")
c = B("c")
h = A("h")
d = A("d")
k = A("k")
l = A("l")
e = A("e")
f = B("f")
i = A("i")
b = A("b")

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

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

n = A("n")
c = B("c")
h = A("h")
d = A("d")
k = A("k")
l = A("l")
e = A("e")
f = B("f")
i = A("i")
b = A("b")

n.t = f
c.r = f
h.t = f
d.t = f
k.t = c
l.t = c
e.t = c
f.r = c
i.t = c
b.t = f
assert b.t.r.r.r.r.r.r.txt == "f"