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

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

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

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

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

f = A("f")
k = B("k")
b = C("b")
g = D("g")
j = E("j")
d = C("d")
e = D("e")

f.p = g
f.o = d
f.x = b
f.q = k
f.y = k
k.x = g
k.w = j
k.q = f
b.r = k
b.q = f
g.y = f
g.u = b
g.p = k
g.t = k
g.s = e
j.z = f
d.r = k
d.q = f
e.y = f
e.u = b
e.p = k
e.t = k
e.s = g
assert k.w.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.o: C = None
        self.x: C = None
        self.q: B = None
        self.y: B = None
        self.txt = txt

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

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

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

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

f = A("f")
k = B("k")
b = C("b")
g = D("g")
j = E("j")
d = C("d")
e = D("e")

f.p = g
f.o = d
f.x = b
f.q = k
f.y = k
k.x = g
k.w = j
k.q = f
b.r = k
b.q = f
g.y = f
g.u = b
g.p = k
g.t = k
g.s = e
j.z = f
d.r = k
d.q = f
e.y = f
e.u = b
e.p = k
e.t = k
e.s = g
assert k.w.z.y.txt == "k"