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

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

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

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

i.t = k
i.v = c
i.r = j
k.v = j
j.y = k
j.s = k
c.t = k
c.v = i
c.r = j
assert c.v.r.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.v: A = None
        self.r: C = None
        self.txt = txt

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

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

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

i.t = k
i.v = c
i.r = j
k.v = j
j.y = k
j.s = k
c.t = k
c.v = i
c.r = j
assert c.v.r.y.v.txt == "j"