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

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

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

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

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

h.q = l
h.p = d
g.y = n
g.p = j
l.u = a
l.w = d
i.q = n
i.w = n
i.u = l
i.t = l
a.u = l
a.w = l
n.q = i
n.w = i
n.u = d
n.t = l
d.u = l
d.w = a
j.y = i
j.p = g
assert a.u.w.u.u.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.p: C = None
        self.txt = txt

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

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

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

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

h.q = l
h.p = d
g.y = n
g.p = j
l.u = a
l.w = d
i.q = n
i.w = n
i.u = l
i.t = l
a.u = l
a.w = l
n.q = i
n.w = i
n.u = d
n.t = l
d.u = l
d.w = a
j.y = i
j.p = g
assert a.u.w.u.u.w.w.txt == "d"