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

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

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

c = A("c")
a = B("a")
k = C("k")
l = A("l")

c.w = l
a.x = k
a.p = c
k.t = a
l.w = c
assert l.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

c = A("c")
a = B("a")
k = C("k")
l = A("l")

c.w = l
a.x = k
a.p = c
k.t = a
l.w = c
assert l.w.w.w.w.txt == "l"