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

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

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

class D:
    def __init__(self, txt: str):
        self.s: E = None
        self.x: C = None
        self.o: B = None
        self.txt = txt

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

g = A("g")
d = B("d")
b = C("b")
k = D("k")
j = E("j")
n = E("n")

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

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

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

class D:
    def __init__(self, txt: str):
        self.s: E = None
        self.x: C = None
        self.o: B = None
        self.txt = txt

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

g = A("g")
d = B("d")
b = C("b")
k = D("k")
j = E("j")
n = E("n")

g.r = k
g.u = j
d.o = k
b.y = n
b.q = g
k.s = j
k.x = b
k.o = d
j.p = n
j.y = n
j.r = g
j.v = g
n.p = j
n.y = j
n.r = g
n.v = g
assert n.p.r.u.y.txt == "n"