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

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

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

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.s: C = None
        self.q: A = None
        self.z: B = None
        self.txt = txt

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

d.p = h
d.v = h
h.v = k
h.o = b
k.x = d
k.r = b
k.v = i
i.y = h
i.s = k
i.q = d
i.z = b
b.v = k
b.o = h
a.y = b
a.z = b
a.s = k
a.q = d
assert h.o.v.x.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.s: C = None
        self.q: A = None
        self.z: B = None
        self.txt = txt

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

d.p = h
d.v = h
h.v = k
h.o = b
k.x = d
k.r = b
k.v = i
i.y = h
i.s = k
i.q = d
i.z = b
b.v = k
b.o = h
a.y = b
a.z = b
a.s = k
a.q = d
assert h.o.v.x.p.v.txt == "k"