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

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

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

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

k.w = j
k.q = j
l.s = c
b.v = c
f.s = c
g.s = c
j.w = k
j.q = k
c.v = d
d.v = c
assert f.s.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.q: A = None
        self.txt = txt

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

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

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

k.w = j
k.q = j
l.s = c
b.v = c
f.s = c
g.s = c
j.w = k
j.q = k
c.v = d
d.v = c
assert f.s.v.v.v.v.v.v.txt == "c"