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

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

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.o: B = None
        self.w: B = None
        self.v: D = None
        self.y: A = None
        self.txt = txt

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

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

c = A("c")
n = B("n")
j = C("j")
m = D("m")
g = E("g")
f = A("f")

c.r = j
c.q = f
c.s = m
n.v = f
n.o = c
j.s = g
j.o = n
j.w = n
j.v = m
j.y = c
m.u = f
g.v = f
f.r = j
f.q = c
f.s = m
assert n.v.q.q.s.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.q: A = None
        self.s: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.o: B = None
        self.w: B = None
        self.v: D = None
        self.y: A = None
        self.txt = txt

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

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

c = A("c")
n = B("n")
j = C("j")
m = D("m")
g = E("g")
f = A("f")

c.r = j
c.q = f
c.s = m
n.v = f
n.o = c
j.s = g
j.o = n
j.w = n
j.v = m
j.y = c
m.u = f
g.v = f
f.r = j
f.q = c
f.s = m
assert n.v.q.q.s.u.r.txt == "j"