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

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

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

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

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

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

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

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

g.v = b
g.s = b
g.u = c
i.s = m
i.v = b
h.o = m
h.p = g
c.s = i
c.v = b
l.v = b
l.u = c
l.s = h
b.o = c
b.p = l
m.s = a
m.v = h
a.s = m
a.v = b
assert b.o.s.s.s.txt == "a"