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

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

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

l = A("l")
j = B("j")
f = C("f")
g = C("g")
d = C("d")
c = B("c")

l.s = f
j.q = c
f.y = l
f.u = l
g.y = l
g.u = l
d.y = l
d.u = l
c.q = j
assert l.s.y.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

l = A("l")
j = B("j")
f = C("f")
g = C("g")
d = C("d")
c = B("c")

l.s = f
j.q = c
f.y = l
f.u = l
g.y = l
g.u = l
d.y = l
d.u = l
c.q = j
assert l.s.y.s.y.txt == "l"