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

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

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

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

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

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

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

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

n.t = j
n.w = k
i.u = j
i.y = n
j.r = i
k.t = j
k.w = n
assert j.r.y.t.r.txt == "i"