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

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

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

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

b.v = k
b.p = n
n.w = i
k.t = n
i.v = k
i.p = n
l.t = n
assert i.p.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.p: B = None
        self.txt = txt

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

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

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

b.v = k
b.p = n
n.w = i
k.t = n
i.v = k
i.p = n
l.t = n
assert i.p.w.p.txt == "n"