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

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

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

h = A("h")
i = B("i")
g = C("g")
l = A("l")
c = B("c")
d = A("d")
e = A("e")
b = B("b")
m = A("m")

h.u = l
h.s = g
i.o = m
i.q = b
g.v = c
l.u = m
l.s = g
c.o = l
c.q = b
d.u = h
d.s = g
e.u = m
e.s = g
b.o = m
b.q = c
m.u = e
m.s = g
assert d.s.v.o.u.s.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.s: C = None
        self.txt = txt

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

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

h = A("h")
i = B("i")
g = C("g")
l = A("l")
c = B("c")
d = A("d")
e = A("e")
b = B("b")
m = A("m")

h.u = l
h.s = g
i.o = m
i.q = b
g.v = c
l.u = m
l.s = g
c.o = l
c.q = b
d.u = h
d.s = g
e.u = m
e.s = g
b.o = m
b.q = c
m.u = e
m.s = g
assert d.s.v.o.u.s.v.o.txt == "l"