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

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

d = A("d")
j = B("j")
m = B("m")
c = A("c")
g = B("g")
h = B("h")
f = B("f")
k = B("k")
b = A("b")
e = B("e")

d.z = c
d.y = c
j.s = c
m.s = b
c.z = d
c.y = d
g.s = d
h.s = b
f.s = c
k.s = c
b.z = d
b.y = d
e.s = d
assert h.s.y.y.z.z.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.y: A = None
        self.txt = txt

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

d = A("d")
j = B("j")
m = B("m")
c = A("c")
g = B("g")
h = B("h")
f = B("f")
k = B("k")
b = A("b")
e = B("e")

d.z = c
d.y = c
j.s = c
m.s = b
c.z = d
c.y = d
g.s = d
h.s = b
f.s = c
k.s = c
b.z = d
b.y = d
e.s = d
assert h.s.y.y.z.z.y.z.txt == "c"