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

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

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

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

k = A("k")
f = B("f")
n = C("n")
d = D("d")
h = A("h")
l = B("l")
i = D("i")
c = B("c")
a = C("a")

k.u = a
k.x = a
f.t = k
f.p = d
f.q = i
f.v = i
n.s = c
n.x = c
n.q = f
n.v = h
d.s = n
d.t = i
d.u = i
h.u = a
h.x = n
l.t = k
l.p = d
l.q = d
l.v = d
i.s = n
i.t = d
i.u = d
c.t = k
c.p = i
c.v = i
c.q = d
a.s = f
a.x = l
a.q = c
a.v = h
assert f.p.t.s.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.x: C = None
        self.txt = txt

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

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

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

k = A("k")
f = B("f")
n = C("n")
d = D("d")
h = A("h")
l = B("l")
i = D("i")
c = B("c")
a = C("a")

k.u = a
k.x = a
f.t = k
f.p = d
f.q = i
f.v = i
n.s = c
n.x = c
n.q = f
n.v = h
d.s = n
d.t = i
d.u = i
h.u = a
h.x = n
l.t = k
l.p = d
l.q = d
l.v = d
i.s = n
i.t = d
i.u = d
c.t = k
c.p = i
c.v = i
c.q = d
a.s = f
a.x = l
a.q = c
a.v = h
assert f.p.t.s.q.t.txt == "k"