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

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

g = A("g")
n = B("n")
j = B("j")
i = A("i")
f = B("f")
e = B("e")
c = A("c")
k = A("k")

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

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

g = A("g")
n = B("n")
j = B("j")
i = A("i")
f = B("f")
e = B("e")
c = A("c")
k = A("k")

g.u = f
g.z = k
n.w = k
n.t = k
j.w = g
j.t = c
i.u = e
i.z = k
f.w = k
f.t = i
e.w = c
e.t = i
c.u = f
c.z = k
k.u = n
k.z = i
assert f.w.u.w.u.w.u.txt == "n"