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

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

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

j.x = c
j.t = k
c.x = k
c.y = j
k.x = c
k.t = j
assert j.t.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.t: A = None
        self.txt = txt

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

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

j.x = c
j.t = k
c.x = k
c.y = j
k.x = c
k.t = j
assert j.t.x.x.txt == "k"