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

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

class C:
    def __init__(self, txt: str):
        self.z: E = None
        self.t: B = None
        self.w: A = None
        self.txt = txt

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

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

f = A("f")
m = B("m")
d = C("d")
g = D("g")
h = E("h")
b = D("b")

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

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

class C:
    def __init__(self, txt: str):
        self.z: E = None
        self.t: B = None
        self.w: A = None
        self.txt = txt

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

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

f = A("f")
m = B("m")
d = C("d")
g = D("g")
h = E("h")
b = D("b")

f.r = h
f.z = h
f.x = b
f.p = m
m.v = b
m.o = h
d.z = h
d.t = m
d.w = f
g.v = h
g.u = d
h.x = d
h.p = d
h.u = f
h.v = f
h.y = g
b.v = h
b.u = d
assert d.t.o.y.v.v.x.txt == "b"