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

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

a = A("a")
c = B("c")
g = B("g")
b = B("b")
h = A("h")
j = B("j")
e = A("e")
i = A("i")
n = A("n")
k = A("k")

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

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

a = A("a")
c = B("c")
g = B("g")
b = B("b")
h = A("h")
j = B("j")
e = A("e")
i = A("i")
n = A("n")
k = A("k")

a.z = c
c.w = i
c.u = b
g.w = h
g.u = b
b.w = n
b.u = j
h.z = c
j.w = a
j.u = c
e.z = b
i.z = c
n.z = j
k.z = g
assert c.w.z.u.txt == "b"