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

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

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

g = A("g")
b = B("b")
d = C("d")
a = C("a")
n = C("n")

g.q = b
g.x = n
g.o = a
b.s = g
b.v = g
b.x = g
d.w = b
d.q = g
d.t = g
a.w = b
a.q = g
a.t = g
n.w = b
n.q = g
n.t = g
assert g.q.x.x.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.x: C = None
        self.o: C = None
        self.txt = txt

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

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

g = A("g")
b = B("b")
d = C("d")
a = C("a")
n = C("n")

g.q = b
g.x = n
g.o = a
b.s = g
b.v = g
b.x = g
d.w = b
d.q = g
d.t = g
a.w = b
a.q = g
a.t = g
n.w = b
n.q = g
n.t = g
assert g.q.x.x.q.x.txt == "n"