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

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

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

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

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

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

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

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

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

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

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

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

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