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

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

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

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

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

g = A("g")
m = B("m")
c = C("c")
f = D("f")
k = E("k")
d = A("d")

g.u = m
m.p = g
m.x = c
m.v = d
m.u = k
c.r = m
f.p = k
f.u = m
f.x = c
f.s = c
f.z = c
k.x = g
k.r = c
k.p = f
k.q = m
d.u = m
assert m.p.u.u.r.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

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

g = A("g")
m = B("m")
c = C("c")
f = D("f")
k = E("k")
d = A("d")

g.u = m
m.p = g
m.x = c
m.v = d
m.u = k
c.r = m
f.p = k
f.u = m
f.x = c
f.s = c
f.z = c
k.x = g
k.r = c
k.p = f
k.q = m
d.u = m
assert m.p.u.u.r.r.v.txt == "d"