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

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

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

b = A("b")
g = B("g")
m = C("m")
j = B("j")
d = B("d")
n = C("n")

b.u = g
b.w = m
g.z = m
g.v = b
g.s = j
m.s = b
m.w = d
m.x = n
j.z = m
j.v = b
j.s = d
d.z = m
d.v = b
d.s = g
n.s = b
n.w = d
n.x = m
assert j.z.s.w.s.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: C = None
        self.txt = txt

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

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

b = A("b")
g = B("g")
m = C("m")
j = B("j")
d = B("d")
n = C("n")

b.u = g
b.w = m
g.z = m
g.v = b
g.s = j
m.s = b
m.w = d
m.x = n
j.z = m
j.v = b
j.s = d
d.z = m
d.v = b
d.s = g
n.s = b
n.w = d
n.x = m
assert j.z.s.w.s.u.z.txt == "m"