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: B = None
        self.x: B = None
        self.txt = txt

h = A("h")
n = B("n")
i = A("i")
b = A("b")
f = B("f")

h.v = i
h.t = b
n.s = f
n.x = f
i.v = b
i.t = h
b.v = i
b.t = i
f.s = n
f.x = n
assert h.t.t.t.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: B = None
        self.x: B = None
        self.txt = txt

h = A("h")
n = B("n")
i = A("i")
b = A("b")
f = B("f")

h.v = i
h.t = b
n.s = f
n.x = f
i.v = b
i.t = h
b.v = i
b.t = i
f.s = n
f.x = n
assert h.t.t.t.txt == "h"