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

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

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

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

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

a.p = f
a.u = g
a.q = n
f.p = k
f.y = d
f.w = j
e.q = j
j.y = m
j.w = k
j.p = i
j.t = g
g.p = n
g.q = n
g.u = a
n.p = a
n.y = e
n.w = j
i.q = j
d.q = j
k.p = n
k.u = a
k.q = f
m.q = j
assert e.q.y.q.p.q.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: A = None
        self.q: B = None
        self.txt = txt

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

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

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

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

a.p = f
a.u = g
a.q = n
f.p = k
f.y = d
f.w = j
e.q = j
j.y = m
j.w = k
j.p = i
j.t = g
g.p = n
g.q = n
g.u = a
n.p = a
n.y = e
n.w = j
i.q = j
d.q = j
k.p = n
k.u = a
k.q = f
m.q = j
assert e.q.y.q.p.q.p.q.txt == "j"