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

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

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

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

h = A("h")
l = B("l")
f = C("f")
e = D("e")
i = A("i")
a = C("a")
g = D("g")
j = C("j")
d = B("d")
c = B("c")

h.o = g
l.z = i
l.t = d
f.s = h
f.p = e
f.w = a
f.u = j
e.t = g
e.o = g
e.p = h
i.o = e
a.s = i
a.p = g
a.w = f
a.u = j
g.t = e
g.o = e
g.p = h
j.s = h
j.p = e
j.w = f
j.u = a
d.z = i
d.t = c
c.z = h
c.t = d
assert e.p.o.p.o.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

h = A("h")
l = B("l")
f = C("f")
e = D("e")
i = A("i")
a = C("a")
g = D("g")
j = C("j")
d = B("d")
c = B("c")

h.o = g
l.z = i
l.t = d
f.s = h
f.p = e
f.w = a
f.u = j
e.t = g
e.o = g
e.p = h
i.o = e
a.s = i
a.p = g
a.w = f
a.u = j
g.t = e
g.o = e
g.p = h
j.s = h
j.p = e
j.w = f
j.u = a
d.z = i
d.t = c
c.z = h
c.t = d
assert e.p.o.p.o.p.o.txt == "g"