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

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

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

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

k = A("k")
h = B("h")
a = C("a")
f = D("f")
l = C("l")
n = B("n")
j = A("j")
c = B("c")
b = A("b")
e = B("e")

k.u = a
k.x = a
k.o = j
h.p = f
h.r = j
a.q = k
a.p = l
f.u = a
l.q = b
l.p = a
n.p = f
n.r = j
j.u = a
j.x = l
j.o = b
c.p = f
c.r = j
b.u = a
b.x = l
b.o = k
e.p = f
e.r = j
assert j.u.p.p.p.p.p.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.x: C = None
        self.o: A = None
        self.txt = txt

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

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

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

k = A("k")
h = B("h")
a = C("a")
f = D("f")
l = C("l")
n = B("n")
j = A("j")
c = B("c")
b = A("b")
e = B("e")

k.u = a
k.x = a
k.o = j
h.p = f
h.r = j
a.q = k
a.p = l
f.u = a
l.q = b
l.p = a
n.p = f
n.r = j
j.u = a
j.x = l
j.o = b
c.p = f
c.r = j
b.u = a
b.x = l
b.o = k
e.p = f
e.r = j
assert j.u.p.p.p.p.p.q.o.txt == "k"