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

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

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

d = A("d")
g = B("g")
m = C("m")
j = D("j")
h = E("h")
i = A("i")
b = C("b")
c = E("c")
a = A("a")
e = B("e")

d.y = g
d.p = a
d.q = e
g.q = i
g.s = j
g.o = j
g.p = e
m.z = a
m.y = a
m.p = b
j.q = b
h.o = i
i.y = g
i.q = g
i.p = d
b.z = i
b.y = a
b.p = m
c.o = d
a.y = e
a.p = d
a.q = g
e.q = d
e.s = j
e.o = j
e.p = g
assert g.p.q.q.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.p: A = None
        self.q: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

d = A("d")
g = B("g")
m = C("m")
j = D("j")
h = E("h")
i = A("i")
b = C("b")
c = E("c")
a = A("a")
e = B("e")

d.y = g
d.p = a
d.q = e
g.q = i
g.s = j
g.o = j
g.p = e
m.z = a
m.y = a
m.p = b
j.q = b
h.o = i
i.y = g
i.q = g
i.p = d
b.z = i
b.y = a
b.p = m
c.o = d
a.y = e
a.p = d
a.q = g
e.q = d
e.s = j
e.o = j
e.p = g
assert g.p.q.q.q.y.txt == "g"