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

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

e = A("e")
j = B("j")
m = A("m")
h = B("h")
b = A("b")
n = B("n")
c = A("c")

e.z = n
e.p = h
j.w = c
j.u = m
m.z = n
m.p = h
h.w = m
h.u = c
b.z = j
b.p = h
n.w = e
n.u = m
c.z = n
c.p = n
assert e.p.w.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.p: B = None
        self.txt = txt

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

e = A("e")
j = B("j")
m = A("m")
h = B("h")
b = A("b")
n = B("n")
c = A("c")

e.z = n
e.p = h
j.w = c
j.u = m
m.z = n
m.p = h
h.w = m
h.u = c
b.z = j
b.p = h
n.w = e
n.u = m
c.z = n
c.p = n
assert e.p.w.z.u.txt == "m"