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

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

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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: D = None
        self.z: D = None
        self.r: B = None
        self.txt = txt

b = A("b")
f = B("f")
a = C("a")
n = D("n")
i = B("i")
k = D("k")

b.v = n
b.y = f
b.r = f
b.p = a
f.w = n
f.y = n
f.o = b
a.w = i
n.y = a
n.x = k
n.z = k
n.r = f
i.w = n
i.y = k
i.o = b
k.y = a
k.x = n
k.z = n
k.r = f
assert n.r.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: B = None
        self.r: B = None
        self.p: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: D = None
        self.z: D = None
        self.r: B = None
        self.txt = txt

b = A("b")
f = B("f")
a = C("a")
n = D("n")
i = B("i")
k = D("k")

b.v = n
b.y = f
b.r = f
b.p = a
f.w = n
f.y = n
f.o = b
a.w = i
n.y = a
n.x = k
n.z = k
n.r = f
i.w = n
i.y = k
i.o = b
k.y = a
k.x = n
k.z = n
k.r = f
assert n.r.w.y.txt == "a"