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

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

h = A("h")
i = B("i")
j = B("j")

h.u = j
h.y = i
i.t = j
i.s = h
j.t = i
j.s = h
assert h.y.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.y: B = None
        self.txt = txt

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

h = A("h")
i = B("i")
j = B("j")

h.u = j
h.y = i
i.t = j
i.s = h
j.t = i
j.s = h
assert h.y.t.s.txt == "h"