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

class B:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.o: A = None
        self.w: C = None
        self.y: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.p: C = None
        self.t: D = None
        self.x: D = None
        self.w: D = None
        self.q: A = None
        self.txt = txt

a = A("a")
f = B("f")
d = C("d")
k = D("k")
e = E("e")
n = C("n")
c = E("c")
j = A("j")
m = D("m")

a.o = m
a.p = j
f.z = m
d.v = k
d.y = k
d.o = a
d.w = n
k.q = a
e.p = n
e.t = m
e.x = m
e.w = k
e.q = j
n.v = m
n.y = m
n.o = a
n.w = d
c.p = d
c.t = m
c.x = m
c.w = k
c.q = j
j.o = k
j.p = a
m.q = a
assert c.w.q.p.p.p.o.q.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.p: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.o: A = None
        self.w: C = None
        self.y: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.p: C = None
        self.t: D = None
        self.x: D = None
        self.w: D = None
        self.q: A = None
        self.txt = txt

a = A("a")
f = B("f")
d = C("d")
k = D("k")
e = E("e")
n = C("n")
c = E("c")
j = A("j")
m = D("m")

a.o = m
a.p = j
f.z = m
d.v = k
d.y = k
d.o = a
d.w = n
k.q = a
e.p = n
e.t = m
e.x = m
e.w = k
e.q = j
n.v = m
n.y = m
n.o = a
n.w = d
c.p = d
c.t = m
c.x = m
c.w = k
c.q = j
j.o = k
j.p = a
m.q = a
assert c.w.q.p.p.p.o.q.o.q.txt == "a"