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

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

b = A("b")
i = B("i")
d = A("d")
k = B("k")
m = B("m")
e = A("e")
l = A("l")
n = B("n")
f = B("f")
j = B("j")

b.z = e
b.x = l
i.w = k
i.z = k
d.z = e
d.x = l
k.w = i
k.z = f
m.w = k
m.z = j
e.z = l
e.x = b
l.z = d
l.x = e
n.w = k
n.z = f
f.w = m
f.z = k
j.w = f
j.z = f
assert d.x.z.z.x.x.z.z.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.x: A = None
        self.txt = txt

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

b = A("b")
i = B("i")
d = A("d")
k = B("k")
m = B("m")
e = A("e")
l = A("l")
n = B("n")
f = B("f")
j = B("j")

b.z = e
b.x = l
i.w = k
i.z = k
d.z = e
d.x = l
k.w = i
k.z = f
m.w = k
m.z = j
e.z = l
e.x = b
l.z = d
l.x = e
n.w = k
n.z = f
f.w = m
f.z = k
j.w = f
j.z = f
assert d.x.z.z.x.x.z.z.x.z.txt == "e"