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

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

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

j = A("j")
l = B("l")
m = C("m")
f = C("f")
a = C("a")
k = A("k")

j.q = l
j.r = l
l.w = j
l.x = k
m.x = a
m.v = l
f.x = a
f.v = l
a.x = m
a.v = l
k.q = l
k.r = l
assert l.w.q.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: B = None
        self.txt = txt

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

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

j = A("j")
l = B("l")
m = C("m")
f = C("f")
a = C("a")
k = A("k")

j.q = l
j.r = l
l.w = j
l.x = k
m.x = a
m.v = l
f.x = a
f.v = l
a.x = m
a.v = l
k.q = l
k.r = l
assert l.w.q.x.q.txt == "l"