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

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

j = A("j")
d = B("d")
l = A("l")
b = B("b")
n = B("n")
h = B("h")
e = A("e")

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

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

j = A("j")
d = B("d")
l = A("l")
b = B("b")
n = B("n")
h = B("h")
e = A("e")

j.x = l
j.z = l
d.w = j
l.x = j
l.z = e
b.w = j
n.w = j
h.w = j
e.x = j
e.z = j
assert j.z.x.z.z.x.x.txt == "l"