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

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

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

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

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

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

l.y = i
l.z = f
n.t = l
j.t = f
c.t = l
f.y = l
f.z = d
d.y = i
d.z = f
i.y = d
i.z = d
h.t = f
assert d.y.z.y.y.txt == "d"