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

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

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

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

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

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

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

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

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

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

l.v = i
l.x = n
b.t = l
m.q = c
c.p = b
c.r = b
c.s = m
c.v = l
n.p = b
n.r = b
n.s = m
n.v = i
i.v = l
i.x = n
assert n.p.t.v.v.txt == "l"