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

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

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

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

l = A("l")
e = B("e")
i = C("i")
d = D("d")
j = D("j")
b = B("b")
a = B("a")
g = D("g")
m = C("m")

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

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

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

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

l = A("l")
e = B("e")
i = C("i")
d = D("d")
j = D("j")
b = B("b")
a = B("a")
g = D("g")
m = C("m")

l.w = j
l.p = i
e.s = l
e.y = j
e.x = i
e.p = d
i.u = j
d.y = m
d.q = i
d.p = l
d.r = b
j.y = m
j.q = m
j.p = l
j.r = a
b.s = l
b.y = j
b.x = i
b.p = d
a.s = l
a.y = g
a.x = i
a.p = d
g.y = i
g.q = m
g.p = l
g.r = a
m.u = g
assert a.p.r.p.q.u.q.u.y.txt == "i"