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

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

c = A("c")
n = B("n")
h = A("h")
k = B("k")

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

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

c = A("c")
n = B("n")
h = A("h")
k = B("k")

c.x = n
n.t = h
h.x = k
k.t = c
assert c.x.t.x.t.txt == "c"