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

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

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

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

d = A("d")
g = B("g")
l = C("l")
n = D("n")
i = B("i")
b = D("b")
m = B("m")
e = B("e")
j = D("j")
h = C("h")

d.o = g
g.z = l
g.w = l
g.v = l
g.p = h
l.t = h
l.o = h
l.z = h
l.w = d
n.r = g
i.z = l
i.v = l
i.p = h
i.w = h
b.r = m
m.z = h
m.p = h
m.w = h
m.v = h
e.z = h
e.p = h
e.w = l
e.v = l
j.r = g
h.t = l
h.o = l
h.z = l
h.w = d
assert e.p.z.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

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

d = A("d")
g = B("g")
l = C("l")
n = D("n")
i = B("i")
b = D("b")
m = B("m")
e = B("e")
j = D("j")
h = C("h")

d.o = g
g.z = l
g.w = l
g.v = l
g.p = h
l.t = h
l.o = h
l.z = h
l.w = d
n.r = g
i.z = l
i.v = l
i.p = h
i.w = h
b.r = m
m.z = h
m.p = h
m.w = h
m.v = h
e.z = h
e.p = h
e.w = l
e.v = l
j.r = g
h.t = l
h.o = l
h.z = l
h.w = d
assert e.p.z.t.w.txt == "d"