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

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

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

k.u = a
k.t = n
c.z = n
c.r = k
a.u = k
a.t = n
n.z = c
n.r = a
assert a.t.r.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.t: B = None
        self.txt = txt

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

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

k.u = a
k.t = n
c.z = n
c.r = k
a.u = k
a.t = n
n.z = c
n.r = a
assert a.t.r.u.t.txt == "n"