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

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.p: D = None
        self.q: A = None
        self.r: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.s: B = None
        self.u: C = None
        self.o: C = None
        self.txt = txt

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

n.x = d
n.t = d
g.x = d
g.p = d
g.q = l
g.r = e
i.u = g
d.y = e
d.u = e
d.s = g
d.o = i
h.x = d
h.t = d
e.u = g
l.x = d
l.t = d
assert i.u.r.u.p.o.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.t: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.p: D = None
        self.q: A = None
        self.r: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.s: B = None
        self.u: C = None
        self.o: C = None
        self.txt = txt

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

n.x = d
n.t = d
g.x = d
g.p = d
g.q = l
g.r = e
i.u = g
d.y = e
d.u = e
d.s = g
d.o = i
h.x = d
h.t = d
e.u = g
l.x = d
l.t = d
assert i.u.r.u.p.o.u.q.txt == "l"