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

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

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

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

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

f = A("f")
b = B("b")
k = C("k")
m = D("m")
a = E("a")

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

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

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

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

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

f = A("f")
b = B("b")
k = C("k")
m = D("m")
a = E("a")

f.y = a
f.q = m
f.v = b
f.z = b
b.t = m
b.s = a
k.r = f
k.y = m
m.y = f
m.x = f
a.y = k
a.s = k
a.w = b
assert k.y.x.y.s.y.txt == "m"