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

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

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

m = A("m")
h = B("h")
a = C("a")
c = C("c")
g = C("g")

m.v = h
m.o = h
h.x = m
h.t = m
a.w = g
c.w = g
g.w = c
assert g.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.o: B = None
        self.txt = txt

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

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

m = A("m")
h = B("h")
a = C("a")
c = C("c")
g = C("g")

m.v = h
m.o = h
h.x = m
h.t = m
a.w = g
c.w = g
g.w = c
assert g.w.w.w.txt == "c"