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

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

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

g = A("g")
i = B("i")
f = C("f")
a = B("a")
c = C("c")
h = A("h")

g.x = c
i.w = a
i.s = a
f.t = c
f.o = h
f.s = h
a.w = i
a.s = i
c.t = f
c.o = g
c.s = g
h.x = f
assert i.s.w.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

g = A("g")
i = B("i")
f = C("f")
a = B("a")
c = C("c")
h = A("h")

g.x = c
i.w = a
i.s = a
f.t = c
f.o = h
f.s = h
a.w = i
a.s = i
c.t = f
c.o = g
c.s = g
h.x = f
assert i.s.w.s.s.txt == "i"