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.u: A = None
        self.txt = txt

m = A("m")
f = B("f")
d = A("d")
n = A("n")
l = A("l")
j = A("j")
c = B("c")
h = B("h")
e = B("e")

m.y = j
f.t = j
f.u = j
d.y = m
n.y = d
l.y = n
j.y = m
c.t = l
c.u = n
h.t = j
h.u = j
e.t = j
e.u = m
assert d.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.u: A = None
        self.txt = txt

m = A("m")
f = B("f")
d = A("d")
n = A("n")
l = A("l")
j = A("j")
c = B("c")
h = B("h")
e = B("e")

m.y = j
f.t = j
f.u = j
d.y = m
n.y = d
l.y = n
j.y = m
c.t = l
c.u = n
h.t = j
h.u = j
e.t = j
e.u = m
assert d.y.y.y.y.y.txt == "m"