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

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

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

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

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

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

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

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

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

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

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

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

h.q = f
f.q = h
f.p = h
f.r = h
f.y = n
f.w = b
b.t = n
b.w = n
b.p = f
b.z = f
b.v = h
n.y = a
e.o = f
a.o = f
assert e.o.w.v.q.r.txt == "h"