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

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

n = A("n")
e = B("e")
m = B("m")
b = A("b")
h = B("h")

n.u = b
n.t = b
e.s = m
e.p = h
m.s = h
m.p = h
b.u = n
b.t = n
h.s = e
h.p = e
assert b.t.u.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.t: A = None
        self.txt = txt

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

n = A("n")
e = B("e")
m = B("m")
b = A("b")
h = B("h")

n.u = b
n.t = b
e.s = m
e.p = h
m.s = h
m.p = h
b.u = n
b.t = n
h.s = e
h.p = e
assert b.t.u.t.t.txt == "b"