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

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

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

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

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

k = A("k")
g = B("g")
b = C("b")
e = D("e")
m = E("m")
h = A("h")
i = B("i")

k.t = h
k.z = h
k.w = e
g.q = e
b.r = m
b.q = e
b.s = h
e.w = k
e.s = g
m.s = e
h.t = k
h.z = k
h.w = e
i.q = e
assert k.w.w.t.t.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.z: A = None
        self.w: D = None
        self.txt = txt

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

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

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

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

k = A("k")
g = B("g")
b = C("b")
e = D("e")
m = E("m")
h = A("h")
i = B("i")

k.t = h
k.z = h
k.w = e
g.q = e
b.r = m
b.q = e
b.s = h
e.w = k
e.s = g
m.s = e
h.t = k
h.z = k
h.w = e
i.q = e
assert k.w.w.t.t.w.w.txt == "k"