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

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

b = A("b")
k = B("k")
h = B("h")
n = A("n")

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

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

b = A("b")
k = B("k")
h = B("h")
n = A("n")

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