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

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

b = A("b")
m = B("m")
j = B("j")
h = A("h")

b.x = m
b.t = h
m.x = j
m.u = h
j.x = m
j.u = h
h.x = j
h.t = b
assert j.u.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.t: A = None
        self.txt = txt

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

b = A("b")
m = B("m")
j = B("j")
h = A("h")

b.x = m
b.t = h
m.x = j
m.u = h
j.x = m
j.u = h
h.x = j
h.t = b
assert j.u.t.x.txt == "m"