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

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

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

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

d = A("d")
b = B("b")
i = C("i")
k = D("k")
l = D("l")

d.v = i
b.s = d
i.p = d
i.w = d
i.r = k
i.x = b
k.r = b
k.o = d
k.p = d
k.w = l
l.r = b
l.o = d
l.p = d
l.w = k
assert k.p.v.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

d = A("d")
b = B("b")
i = C("i")
k = D("k")
l = D("l")

d.v = i
b.s = d
i.p = d
i.w = d
i.r = k
i.x = b
k.r = b
k.o = d
k.p = d
k.w = l
l.r = b
l.o = d
l.p = d
l.w = k
assert k.p.v.r.p.txt == "d"