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

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

h = A("h")
l = B("l")
i = A("i")
g = B("g")

h.t = i
l.u = g
i.t = h
g.u = l
assert g.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

h = A("h")
l = B("l")
i = A("i")
g = B("g")

h.t = i
l.u = g
i.t = h
g.u = l
assert g.u.u.u.txt == "l"