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

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

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

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

h = A("h")
l = B("l")
i = C("i")
a = D("a")
k = B("k")
m = C("m")
d = D("d")
g = D("g")

h.x = l
h.v = d
h.z = m
l.t = k
l.p = k
l.q = d
l.w = h
i.s = h
i.p = h
i.w = m
i.v = m
a.q = d
a.o = k
k.t = l
k.p = l
k.q = d
k.w = h
m.s = h
m.p = h
m.w = i
m.v = i
d.q = g
d.o = l
g.q = a
g.o = l
assert g.o.q.q.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.v: D = None
        self.z: C = None
        self.txt = txt

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

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

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

h = A("h")
l = B("l")
i = C("i")
a = D("a")
k = B("k")
m = C("m")
d = D("d")
g = D("g")

h.x = l
h.v = d
h.z = m
l.t = k
l.p = k
l.q = d
l.w = h
i.s = h
i.p = h
i.w = m
i.v = m
a.q = d
a.o = k
k.t = l
k.p = l
k.q = d
k.w = h
m.s = h
m.p = h
m.w = i
m.v = i
d.q = g
d.o = l
g.q = a
g.o = l
assert g.o.q.q.o.w.txt == "h"