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

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

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

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

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

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

j.x = b
j.y = g
g.z = f
b.o = m
b.u = j
b.q = g
m.v = b
m.s = b
m.o = f
f.y = b
h.x = b
h.y = g
assert h.x.u.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: B = None
        self.txt = txt

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

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

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

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

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

j.x = b
j.y = g
g.z = f
b.o = m
b.u = j
b.q = g
m.v = b
m.s = b
m.o = f
f.y = b
h.x = b
h.y = g
assert h.x.u.y.z.txt == "f"