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

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

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

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

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

d.w = n
g.o = d
g.q = d
g.v = m
g.r = c
l.v = e
c.q = e
c.u = m
c.r = l
c.t = d
e.q = n
e.u = m
e.r = l
e.t = d
m.o = d
m.q = d
m.v = g
m.r = e
i.o = d
i.q = d
i.v = h
i.r = c
h.o = d
h.q = d
h.v = i
h.r = c
n.q = e
n.u = m
n.r = l
n.t = d
assert h.r.q.u.r.r.v.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

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

d.w = n
g.o = d
g.q = d
g.v = m
g.r = c
l.v = e
c.q = e
c.u = m
c.r = l
c.t = d
e.q = n
e.u = m
e.r = l
e.t = d
m.o = d
m.q = d
m.v = g
m.r = e
i.o = d
i.q = d
i.v = h
i.r = c
h.o = d
h.q = d
h.v = i
h.r = c
n.q = e
n.u = m
n.r = l
n.t = d
assert h.r.q.u.r.r.v.u.o.txt == "d"