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

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

i = A("i")
e = B("e")
k = A("k")
b = A("b")
g = A("g")
m = B("m")

i.w = g
i.u = k
e.u = m
e.z = b
k.w = g
k.u = g
b.w = g
b.u = g
g.w = b
g.u = k
m.u = e
m.z = b
assert i.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.u: A = None
        self.txt = txt

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

i = A("i")
e = B("e")
k = A("k")
b = A("b")
g = A("g")
m = B("m")

i.w = g
i.u = k
e.u = m
e.z = b
k.w = g
k.u = g
b.w = g
b.u = g
g.w = b
g.u = k
m.u = e
m.z = b
assert i.u.u.u.txt == "k"