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

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

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

k = A("k")
h = B("h")
b = C("b")
i = B("i")

k.v = h
k.t = h
k.r = b
h.y = k
h.q = i
b.v = h
b.o = k
i.y = k
i.q = h
assert k.t.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.t: B = None
        self.r: C = None
        self.txt = txt

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

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

k = A("k")
h = B("h")
b = C("b")
i = B("i")

k.v = h
k.t = h
k.r = b
h.y = k
h.q = i
b.v = h
b.o = k
i.y = k
i.q = h
assert k.t.y.v.txt == "h"