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

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

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

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

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

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

b.t = i
i.t = j
i.r = j
h.t = j
j.t = i
j.r = i
assert b.t.r.t.t.txt == "j"