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

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

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

c = A("c")
h = B("h")
m = C("m")
k = B("k")
f = A("f")

c.o = h
c.s = h
c.v = f
h.w = m
h.o = k
m.x = c
m.p = c
k.w = m
k.o = h
f.o = h
f.s = h
f.v = c
assert c.v.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.v: A = None
        self.s: B = None
        self.txt = txt

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

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

c = A("c")
h = B("h")
m = C("m")
k = B("k")
f = A("f")

c.o = h
c.s = h
c.v = f
h.w = m
h.o = k
m.x = c
m.p = c
k.w = m
k.o = h
f.o = h
f.s = h
f.v = c
assert c.v.v.o.txt == "h"