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

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

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

k.u = i
k.v = j
i.u = j
j.u = i
assert j.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.v: B = None
        self.txt = txt

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

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

k.u = i
k.v = j
i.u = j
j.u = i
assert j.u.u.u.txt == "i"