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

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

d = A("d")
b = B("b")
f = A("f")
m = A("m")
n = A("n")
j = A("j")
i = A("i")
h = B("h")

d.y = f
b.t = n
f.y = i
m.y = j
n.y = d
j.y = i
i.y = n
h.t = n
assert f.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

d = A("d")
b = B("b")
f = A("f")
m = A("m")
n = A("n")
j = A("j")
i = A("i")
h = B("h")

d.y = f
b.t = n
f.y = i
m.y = j
n.y = d
j.y = i
i.y = n
h.t = n
assert f.y.y.y.y.y.y.txt == "n"