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

class B:
    def __init__(self, txt: str):
        self.r: E = None
        self.w: B = None
        self.q: E = None
        self.txt = txt

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.r: E = None
        self.w: B = None
        self.q: E = None
        self.txt = txt

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

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

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

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

g.p = a
g.y = c
g.q = c
i.r = a
i.w = j
i.q = n
c.z = m
c.t = a
c.x = a
c.r = g
e.s = c
n.r = c
m.s = c
a.r = c
j.r = n
j.w = i
j.q = a
b.s = c
assert n.r.z.s.r.p.r.txt == "c"