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

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

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

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

d.q = g
d.t = g
d.s = j
g.y = m
j.x = g
j.q = g
m.y = g
assert m.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.t: B = None
        self.s: C = None
        self.txt = txt

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

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

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

d.q = g
d.t = g
d.s = j
g.y = m
j.x = g
j.q = g
m.y = g
assert m.y.y.y.y.txt == "m"