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

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

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

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

b.u = a
a.w = n
l.w = j
n.w = k
k.u = a
j.u = a
assert b.u.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

b.u = a
a.w = n
l.w = j
n.w = k
k.u = a
j.u = a
assert b.u.w.w.txt == "k"