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

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

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

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

c.y = h
c.x = g
c.w = l
k.w = h
l.o = m
g.o = c
h.w = k
m.y = k
m.x = g
m.w = l
assert m.x.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.x: C = None
        self.w: C = None
        self.txt = txt

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

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

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

c.y = h
c.x = g
c.w = l
k.w = h
l.o = m
g.o = c
h.w = k
m.y = k
m.x = g
m.w = l
assert m.x.o.w.txt == "l"