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

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

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

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

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

n.v = b
l.p = b
l.t = b
l.v = b
l.r = n
i.y = n
b.v = n
assert b.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

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

n.v = b
l.p = b
l.t = b
l.v = b
l.r = n
i.y = n
b.v = n
assert b.v.v.v.v.txt == "b"