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

class B:
    def __init__(self, txt: str):
        self.s: C = None
        self.p: E = None
        self.r: B = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.r: E = None
        self.x: A = None
        self.o: C = None
        self.t: A = None
        self.p: D = None
        self.txt = txt

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

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

class B:
    def __init__(self, txt: str):
        self.s: C = None
        self.p: E = None
        self.r: B = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.r: E = None
        self.x: A = None
        self.o: C = None
        self.t: A = None
        self.p: D = None
        self.txt = txt

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

l.q = m
d.s = m
d.p = n
d.r = g
m.w = n
j.x = m
j.s = l
j.y = n
c.r = n
c.x = l
c.t = l
c.o = b
c.p = j
b.w = c
e.s = b
e.p = c
e.r = d
g.s = m
g.p = n
g.r = e
n.r = c
n.x = l
n.t = l
n.o = m
n.p = j
assert j.y.r.r.x.q.w.r.r.r.txt == "c"