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

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

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

g = A("g")
f = B("f")
m = C("m")
k = B("k")
c = A("c")
b = B("b")
h = B("h")
i = B("i")

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

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

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

g = A("g")
f = B("f")
m = C("m")
k = B("k")
c = A("c")
b = B("b")
h = B("h")
i = B("i")

g.o = c
g.q = k
g.s = b
f.v = h
f.p = m
m.u = c
m.w = c
k.v = h
k.p = m
c.o = g
c.q = i
c.s = h
b.v = k
b.p = m
h.v = b
h.p = m
i.v = k
i.p = m
assert h.p.w.s.p.txt == "m"