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

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

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

a = A("a")
k = B("k")
m = C("m")
h = C("h")

a.r = m
a.x = h
k.v = a
k.o = m
m.t = h
m.r = a
m.y = k
h.t = m
h.r = a
h.y = k
assert m.t.r.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.x: C = None
        self.txt = txt

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

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

a = A("a")
k = B("k")
m = C("m")
h = C("h")

a.r = m
a.x = h
k.v = a
k.o = m
m.t = h
m.r = a
m.y = k
h.t = m
h.r = a
h.y = k
assert m.t.r.x.t.txt == "m"