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

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

i = A("i")
j = B("j")
n = B("n")
a = A("a")

i.r = a
j.t = n
j.u = i
n.t = j
n.u = i
a.r = i
assert i.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

i = A("i")
j = B("j")
n = B("n")
a = A("a")

i.r = a
j.t = n
j.u = i
n.t = j
n.u = i
a.r = i
assert i.r.r.r.r.txt == "i"