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

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.s: D = None
        self.t: D = None
        self.w: E = None
        self.txt = txt

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.s: D = None
        self.t: D = None
        self.w: E = None
        self.txt = txt

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

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

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

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

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