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

class B:
    def __init__(self, txt: str):
        self.u: A = None
        self.z: E = None
        self.txt = txt

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

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

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

k = A("k")
j = B("j")
d = C("d")
c = D("c")
n = E("n")
g = D("g")
h = A("h")

k.p = d
k.y = n
j.u = k
j.z = n
d.s = n
d.t = g
d.r = g
c.w = g
c.r = g
c.u = k
c.q = n
n.x = c
n.y = c
n.p = c
n.r = g
n.s = d
g.w = c
g.r = c
g.u = k
g.q = n
h.p = d
h.y = n
assert j.z.r.u.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: A = None
        self.z: E = None
        self.txt = txt

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

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

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

k = A("k")
j = B("j")
d = C("d")
c = D("c")
n = E("n")
g = D("g")
h = A("h")

k.p = d
k.y = n
j.u = k
j.z = n
d.s = n
d.t = g
d.r = g
c.w = g
c.r = g
c.u = k
c.q = n
n.x = c
n.y = c
n.p = c
n.r = g
n.s = d
g.w = c
g.r = c
g.u = k
g.q = n
h.p = d
h.y = n
assert j.z.r.u.y.r.txt == "g"