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

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

class C:
    def __init__(self, txt: str):
        self.u: D = None
        self.x: D = None
        self.t: C = None
        self.txt = txt

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

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

h.q = b
h.o = a
h.x = f
e.t = i
i.u = f
i.x = f
i.t = b
f.x = h
f.y = n
n.u = f
n.x = f
n.t = i
b.u = f
b.x = f
b.t = n
a.q = b
a.o = h
a.x = f
assert f.x.q.t.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.o: A = None
        self.x: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: D = None
        self.x: D = None
        self.t: C = None
        self.txt = txt

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

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

h.q = b
h.o = a
h.x = f
e.t = i
i.u = f
i.x = f
i.t = b
f.x = h
f.y = n
n.u = f
n.x = f
n.t = i
b.u = f
b.x = f
b.t = n
a.q = b
a.o = h
a.x = f
assert f.x.q.t.x.x.txt == "h"