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.x: A = None
        self.txt = txt

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

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

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

f = A("f")
n = B("n")
c = C("c")
h = D("h")
l = E("l")
a = E("a")

f.q = n
n.q = f
n.x = f
c.o = a
c.t = n
h.w = f
h.p = f
h.o = f
h.q = c
h.y = n
l.p = f
l.v = f
l.w = f
l.t = h
a.p = f
a.v = f
a.w = f
a.t = h
assert h.o.q.q.q.q.q.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.x: A = None
        self.txt = txt

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

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

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

f = A("f")
n = B("n")
c = C("c")
h = D("h")
l = E("l")
a = E("a")

f.q = n
n.q = f
n.x = f
c.o = a
c.t = n
h.w = f
h.p = f
h.o = f
h.q = c
h.y = n
l.p = f
l.v = f
l.w = f
l.t = h
a.p = f
a.v = f
a.w = f
a.t = h
assert h.o.q.q.q.q.q.txt == "n"