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

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

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

e = A("e")
f = B("f")
g = C("g")
h = B("h")
l = C("l")
c = A("c")

e.y = c
e.w = h
f.s = l
g.x = f
g.p = l
g.o = c
h.s = l
l.x = h
l.p = g
l.o = c
c.y = e
c.w = h
assert h.s.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.w: B = None
        self.txt = txt

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

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

e = A("e")
f = B("f")
g = C("g")
h = B("h")
l = C("l")
c = A("c")

e.y = c
e.w = h
f.s = l
g.x = f
g.p = l
g.o = c
h.s = l
l.x = h
l.p = g
l.o = c
c.y = e
c.w = h
assert h.s.p.p.txt == "l"