class A:
    def __init__(self, txt: str):
        self.v: E = None
        self.p: E = None
        self.w: B = None
        self.u: E = None
        self.q: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

n = A("n")
m = B("m")
h = C("h")
e = D("e")
d = E("d")
f = E("f")

n.v = d
n.p = d
n.u = d
n.w = m
n.q = e
m.s = n
m.r = h
m.u = h
m.q = f
m.o = f
h.v = m
h.r = f
e.w = h
d.u = f
f.u = d
assert f.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: E = None
        self.p: E = None
        self.w: B = None
        self.u: E = None
        self.q: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

n = A("n")
m = B("m")
h = C("h")
e = D("e")
d = E("d")
f = E("f")

n.v = d
n.p = d
n.u = d
n.w = m
n.q = e
m.s = n
m.r = h
m.u = h
m.q = f
m.o = f
h.v = m
h.r = f
e.w = h
d.u = f
f.u = d
assert f.u.u.u.u.txt == "f"