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

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

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

c = A("c")
g = B("g")
k = C("k")
h = C("h")
e = C("e")
m = A("m")

c.o = m
c.y = k
g.y = h
g.s = h
g.v = m
k.w = g
k.t = c
h.w = g
h.t = m
e.w = g
e.t = c
m.o = c
m.y = k
assert e.t.o.y.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.y: C = None
        self.txt = txt

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

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

c = A("c")
g = B("g")
k = C("k")
h = C("h")
e = C("e")
m = A("m")

c.o = m
c.y = k
g.y = h
g.s = h
g.v = m
k.w = g
k.t = c
h.w = g
h.t = m
e.w = g
e.t = c
m.o = c
m.y = k
assert e.t.o.y.w.v.txt == "m"