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

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.t: D = None
        self.txt = txt

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

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

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

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

a.y = f
f.q = b
f.t = b
h.u = n
d.r = h
d.q = a
d.p = b
d.s = f
n.s = b
n.y = f
n.t = d
n.v = d
n.u = a
b.r = h
b.q = a
b.p = d
b.s = f
assert h.u.v.q.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.t: D = None
        self.txt = txt

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

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

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

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

a.y = f
f.q = b
f.t = b
h.u = n
d.r = h
d.q = a
d.p = b
d.s = f
n.s = b
n.y = f
n.t = d
n.v = d
n.u = a
b.r = h
b.q = a
b.p = d
b.s = f
assert h.u.v.q.y.q.txt == "b"