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

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

b = A("b")
i = B("i")
h = B("h")
l = A("l")
a = B("a")

b.v = l
b.t = l
i.s = l
i.p = a
h.s = b
h.p = i
l.v = b
l.t = b
a.s = l
a.p = i
assert b.t.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.t: A = None
        self.txt = txt

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

b = A("b")
i = B("i")
h = B("h")
l = A("l")
a = B("a")

b.v = l
b.t = l
i.s = l
i.p = a
h.s = b
h.p = i
l.v = b
l.t = b
a.s = l
a.p = i
assert b.t.v.v.v.txt == "b"