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

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

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

c = A("c")
k = B("k")
d = C("d")
b = A("b")
i = B("i")
e = C("e")
j = A("j")
m = C("m")
g = A("g")

c.q = i
c.v = m
c.p = k
k.p = c
k.o = i
d.x = m
d.z = e
d.w = j
b.q = i
b.v = e
b.p = k
i.p = c
i.o = k
e.x = d
e.z = d
e.w = c
j.q = i
j.p = i
j.v = m
m.x = e
m.z = d
m.w = j
g.q = k
g.p = k
g.v = d
assert g.v.x.w.p.o.o.p.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: C = None
        self.p: B = None
        self.txt = txt

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

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

c = A("c")
k = B("k")
d = C("d")
b = A("b")
i = B("i")
e = C("e")
j = A("j")
m = C("m")
g = A("g")

c.q = i
c.v = m
c.p = k
k.p = c
k.o = i
d.x = m
d.z = e
d.w = j
b.q = i
b.v = e
b.p = k
i.p = c
i.o = k
e.x = d
e.z = d
e.w = c
j.q = i
j.p = i
j.v = m
m.x = e
m.z = d
m.w = j
g.q = k
g.p = k
g.v = d
assert g.v.x.w.p.o.o.p.v.x.txt == "e"