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

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

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

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

i.v = k
i.r = g
c.o = k
g.r = i
k.o = c
assert i.r.r.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.r: C = None
        self.txt = txt

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

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

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

i.v = k
i.r = g
c.o = k
g.r = i
k.o = c
assert i.r.r.v.o.txt == "c"