class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.z: A = None
        self.p: B = 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.t: B = None
        self.v: A = None
        self.z: A = None
        self.txt = txt

n = A("n")
k = B("k")
f = C("f")
g = C("g")
m = B("m")
j = B("j")
h = A("h")

n.s = j
n.z = h
n.p = k
k.o = h
k.q = j
f.t = k
f.v = n
f.z = h
g.t = k
g.v = h
g.z = h
m.o = n
m.q = j
j.o = n
j.q = k
h.s = k
h.z = n
h.p = j
assert j.o.z.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.z: A = None
        self.p: B = 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.t: B = None
        self.v: A = None
        self.z: A = None
        self.txt = txt

n = A("n")
k = B("k")
f = C("f")
g = C("g")
m = B("m")
j = B("j")
h = A("h")

n.s = j
n.z = h
n.p = k
k.o = h
k.q = j
f.t = k
f.v = n
f.z = h
g.t = k
g.v = h
g.z = h
m.o = n
m.q = j
j.o = n
j.q = k
h.s = k
h.z = n
h.p = j
assert j.o.z.s.o.txt == "h"