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

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

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

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

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

m = A("m")
b = B("b")
i = C("i")
n = D("n")
h = E("h")
g = A("g")
a = B("a")

m.s = g
m.y = i
b.q = n
b.r = n
b.w = h
b.y = g
b.s = a
i.x = n
n.o = b
h.s = m
h.t = g
g.s = m
g.y = i
a.q = n
a.r = n
a.w = h
a.y = m
a.s = b
assert b.w.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.y: C = None
        self.txt = txt

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

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

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

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

m = A("m")
b = B("b")
i = C("i")
n = D("n")
h = E("h")
g = A("g")
a = B("a")

m.s = g
m.y = i
b.q = n
b.r = n
b.w = h
b.y = g
b.s = a
i.x = n
n.o = b
h.s = m
h.t = g
g.s = m
g.y = i
a.q = n
a.r = n
a.w = h
a.y = m
a.s = b
assert b.w.s.s.s.txt == "m"