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

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

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

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

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

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

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

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

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

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

l.y = a
g.x = e
g.r = a
g.q = n
e.p = a
h.w = g
h.r = c
h.u = j
j.w = g
j.r = c
j.u = n
c.y = a
a.p = e
b.x = e
b.r = a
b.q = d
n.w = b
n.r = l
n.u = d
d.w = g
d.r = l
d.u = j
assert d.u.u.u.u.w.q.w.r.p.txt == "e"