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

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

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

k = A("k")
b = B("b")
a = C("a")
l = B("l")
n = C("n")

k.x = a
b.y = l
b.w = a
a.u = l
a.q = b
l.y = b
l.w = n
n.u = b
n.q = l
assert b.y.y.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

k = A("k")
b = B("b")
a = C("a")
l = B("l")
n = C("n")

k.x = a
b.y = l
b.w = a
a.u = l
a.q = b
l.y = b
l.w = n
n.u = b
n.q = l
assert b.y.y.y.w.txt == "n"