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

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

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

g = A("g")
l = B("l")
e = C("e")
f = C("f")
a = C("a")
i = A("i")

g.s = l
l.s = f
l.z = e
e.q = l
f.q = l
a.q = l
i.s = l
assert i.s.s.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

g = A("g")
l = B("l")
e = C("e")
f = C("f")
a = C("a")
i = A("i")

g.s = l
l.s = f
l.z = e
e.q = l
f.q = l
a.q = l
i.s = l
assert i.s.s.q.z.txt == "e"