class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.p: E = None
        self.x: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: E = None
        self.w: B = None
        self.o: E = None
        self.q: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: B = None
        self.v: D = None
        self.txt = txt

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

a.r = n
a.p = g
a.x = g
j.u = n
j.s = b
c.r = g
c.o = g
c.w = j
c.q = b
h.z = j
g.r = n
g.u = m
g.v = h
f.z = j
n.r = a
n.p = g
n.x = g
m.u = a
m.s = b
b.z = m
d.r = g
d.o = g
d.w = j
d.q = b
assert h.z.u.p.u.u.r.x.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.p: E = None
        self.x: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: E = None
        self.w: B = None
        self.o: E = None
        self.q: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: B = None
        self.v: D = None
        self.txt = txt

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

a.r = n
a.p = g
a.x = g
j.u = n
j.s = b
c.r = g
c.o = g
c.w = j
c.q = b
h.z = j
g.r = n
g.u = m
g.v = h
f.z = j
n.r = a
n.p = g
n.x = g
m.u = a
m.s = b
b.z = m
d.r = g
d.o = g
d.w = j
d.q = b
assert h.z.u.p.u.u.r.x.r.r.txt == "a"