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

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: B = None
        self.r: B = None
        self.u: A = None
        self.txt = txt

g = A("g")
m = B("m")
d = C("d")
n = D("n")
k = E("k")
b = D("b")
f = A("f")
i = B("i")

g.r = k
g.p = m
g.o = b
m.o = b
m.t = g
m.q = i
d.v = m
d.s = n
d.r = g
n.x = f
k.p = d
k.y = i
k.r = m
k.u = g
b.x = g
f.r = k
f.p = m
f.o = b
i.o = n
i.t = f
i.q = m
assert n.x.p.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.p: B = None
        self.o: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: B = None
        self.r: B = None
        self.u: A = None
        self.txt = txt

g = A("g")
m = B("m")
d = C("d")
n = D("n")
k = E("k")
b = D("b")
f = A("f")
i = B("i")

g.r = k
g.p = m
g.o = b
m.o = b
m.t = g
m.q = i
d.v = m
d.s = n
d.r = g
n.x = f
k.p = d
k.y = i
k.r = m
k.u = g
b.x = g
f.r = k
f.p = m
f.o = b
i.o = n
i.t = f
i.q = m
assert n.x.p.q.q.txt == "m"