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

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

class C:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

a = A("a")
d = B("d")
l = C("l")
g = B("g")

a.s = g
a.o = g
d.q = l
d.u = l
d.x = g
l.y = d
g.q = l
g.u = l
g.x = d
assert a.o.x.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.o: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

a = A("a")
d = B("d")
l = C("l")
g = B("g")

a.s = g
a.o = g
d.q = l
d.u = l
d.x = g
l.y = d
g.q = l
g.u = l
g.x = d
assert a.o.x.x.q.txt == "l"