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

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

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.t: A = None
        self.z: A = None
        self.o: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.v: D = None
        self.q: B = None
        self.y: D = None
        self.txt = txt

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

h.v = i
h.w = a
a.w = d
d.p = b
d.t = h
d.z = h
d.o = i
b.v = i
b.y = i
b.q = a
n.v = i
n.w = a
i.v = b
i.y = b
i.q = a
assert n.v.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.w: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.t: A = None
        self.z: A = None
        self.o: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.v: D = None
        self.q: B = None
        self.y: D = None
        self.txt = txt

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

h.v = i
h.w = a
a.w = d
d.p = b
d.t = h
d.z = h
d.o = i
b.v = i
b.y = i
b.q = a
n.v = i
n.w = a
i.v = b
i.y = b
i.q = a
assert n.v.q.w.txt == "d"