class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.t: B = None
        self.txt = txt

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

m = A("m")
i = B("i")
k = A("k")
e = A("e")
n = A("n")
h = B("h")

m.x = e
m.t = i
i.p = n
i.s = n
k.x = e
k.t = h
e.x = k
e.t = h
n.x = m
n.t = h
h.p = n
h.s = e
assert h.p.x.t.s.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.t: B = None
        self.txt = txt

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

m = A("m")
i = B("i")
k = A("k")
e = A("e")
n = A("n")
h = B("h")

m.x = e
m.t = i
i.p = n
i.s = n
k.x = e
k.t = h
e.x = k
e.t = h
n.x = m
n.t = h
h.p = n
h.s = e
assert h.p.x.t.s.t.p.txt == "n"