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

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

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

h = A("h")
f = B("f")
n = C("n")
i = C("i")
m = C("m")
e = B("e")
b = B("b")
d = C("d")
g = C("g")

h.x = b
h.q = f
h.v = i
f.z = b
f.t = e
f.o = h
n.q = f
n.z = h
n.x = g
i.q = b
i.z = h
i.x = n
m.q = f
m.z = h
m.x = g
e.z = b
e.t = f
e.o = h
b.z = e
b.t = f
b.o = h
d.q = f
d.z = h
d.x = i
g.q = f
g.z = h
g.x = d
assert g.z.q.t.t.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.q: B = None
        self.v: C = None
        self.txt = txt

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

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

h = A("h")
f = B("f")
n = C("n")
i = C("i")
m = C("m")
e = B("e")
b = B("b")
d = C("d")
g = C("g")

h.x = b
h.q = f
h.v = i
f.z = b
f.t = e
f.o = h
n.q = f
n.z = h
n.x = g
i.q = b
i.z = h
i.x = n
m.q = f
m.z = h
m.x = g
e.z = b
e.t = f
e.o = h
b.z = e
b.t = f
b.o = h
d.q = f
d.z = h
d.x = i
g.q = f
g.z = h
g.x = d
assert g.z.q.t.t.z.t.txt == "f"