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

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

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

g = A("g")
h = B("h")
b = C("b")
f = C("f")
e = B("e")
i = C("i")
m = B("m")

g.x = b
g.u = b
h.o = g
h.s = b
h.q = b
b.q = m
b.o = m
b.z = g
f.q = e
f.o = m
f.z = g
e.o = g
e.s = i
e.q = i
i.q = e
i.o = m
i.z = g
m.o = g
m.s = b
m.q = i
assert g.x.o.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.u: C = None
        self.txt = txt

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

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

g = A("g")
h = B("h")
b = C("b")
f = C("f")
e = B("e")
i = C("i")
m = B("m")

g.x = b
g.u = b
h.o = g
h.s = b
h.q = b
b.q = m
b.o = m
b.z = g
f.q = e
f.o = m
f.z = g
e.o = g
e.s = i
e.q = i
i.q = e
i.o = m
i.z = g
m.o = g
m.s = b
m.q = i
assert g.x.o.s.o.txt == "m"