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

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

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

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

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

h.t = e
e.p = k
e.t = l
m.q = e
m.t = g
m.r = g
m.u = c
k.u = c
k.z = l
c.u = k
c.z = d
d.t = e
a.q = e
a.t = g
a.r = g
a.u = k
g.q = e
g.t = m
g.u = k
g.r = a
l.t = e
assert g.u.z.t.t.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

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

h.t = e
e.p = k
e.t = l
m.q = e
m.t = g
m.r = g
m.u = c
k.u = c
k.z = l
c.u = k
c.z = d
d.t = e
a.q = e
a.t = g
a.r = g
a.u = k
g.q = e
g.t = m
g.u = k
g.r = a
l.t = e
assert g.u.z.t.t.t.p.txt == "k"