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

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

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

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

e = A("e")
m = B("m")
j = C("j")
c = D("c")
g = C("g")
a = B("a")
f = C("f")
b = C("b")

e.o = a
e.x = a
e.q = f
e.r = m
m.q = e
m.r = e
m.o = a
m.p = a
j.p = m
j.w = m
j.u = a
j.x = c
c.q = e
c.p = e
c.y = b
g.p = m
g.w = m
g.u = a
g.x = c
a.q = e
a.r = e
a.o = m
a.p = m
f.p = m
f.w = m
f.u = a
f.x = c
b.p = m
b.w = m
b.u = m
b.x = c
assert b.w.r.q.u.p.r.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.q: C = None
        self.x: B = None
        self.r: B = None
        self.txt = txt

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

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

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

e = A("e")
m = B("m")
j = C("j")
c = D("c")
g = C("g")
a = B("a")
f = C("f")
b = C("b")

e.o = a
e.x = a
e.q = f
e.r = m
m.q = e
m.r = e
m.o = a
m.p = a
j.p = m
j.w = m
j.u = a
j.x = c
c.q = e
c.p = e
c.y = b
g.p = m
g.w = m
g.u = a
g.x = c
a.q = e
a.r = e
a.o = m
a.p = m
f.p = m
f.w = m
f.u = a
f.x = c
b.p = m
b.w = m
b.u = m
b.x = c
assert b.w.r.q.u.p.r.r.q.txt == "e"