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

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

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

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

f.o = l
c.s = h
c.y = i
c.v = g
g.y = i
i.s = f
i.y = c
i.v = g
h.o = a
a.o = e
b.y = c
l.o = a
e.o = a
assert g.y.s.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

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

f.o = l
c.s = h
c.y = i
c.v = g
g.y = i
i.s = f
i.y = c
i.v = g
h.o = a
a.o = e
b.y = c
l.o = a
e.o = a
assert g.y.s.o.o.o.o.txt == "a"