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

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

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

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

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

g = A("g")
i = B("i")
k = C("k")
h = D("h")
n = E("n")
f = B("f")
b = D("b")
l = D("l")
m = D("m")
j = D("j")

g.x = k
g.r = k
g.q = n
g.y = h
i.p = j
k.p = g
h.z = k
h.r = k
h.w = g
h.x = g
n.w = l
n.r = h
n.p = j
f.p = l
b.z = k
b.r = k
b.w = g
b.x = g
l.z = k
l.r = k
l.w = g
l.x = g
m.z = k
m.r = k
m.w = g
m.x = g
j.z = k
j.r = k
j.w = g
j.x = g
assert m.x.r.p.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.q: E = None
        self.r: C = None
        self.y: D = None
        self.txt = txt

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

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

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

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

g = A("g")
i = B("i")
k = C("k")
h = D("h")
n = E("n")
f = B("f")
b = D("b")
l = D("l")
m = D("m")
j = D("j")

g.x = k
g.r = k
g.q = n
g.y = h
i.p = j
k.p = g
h.z = k
h.r = k
h.w = g
h.x = g
n.w = l
n.r = h
n.p = j
f.p = l
b.z = k
b.r = k
b.w = g
b.x = g
l.z = k
l.r = k
l.w = g
l.x = g
m.z = k
m.r = k
m.w = g
m.x = g
j.z = k
j.r = k
j.w = g
j.x = g
assert m.x.r.p.y.r.txt == "k"