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

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

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

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

f = A("f")
a = B("a")
e = C("e")
g = D("g")
i = D("i")
h = A("h")
k = D("k")

f.q = e
a.p = k
a.r = e
a.o = h
e.u = f
e.x = k
e.t = k
e.o = h
g.x = f
g.p = f
g.o = e
i.x = f
i.p = f
i.o = e
h.q = e
k.x = h
k.p = h
k.o = e
assert e.u.q.t.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

f = A("f")
a = B("a")
e = C("e")
g = D("g")
i = D("i")
h = A("h")
k = D("k")

f.q = e
a.p = k
a.r = e
a.o = h
e.u = f
e.x = k
e.t = k
e.o = h
g.x = f
g.p = f
g.o = e
i.x = f
i.p = f
i.o = e
h.q = e
k.x = h
k.p = h
k.o = e
assert e.u.q.t.p.q.txt == "e"