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

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

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

d = A("d")
l = B("l")
b = C("b")
n = C("n")
e = B("e")
h = B("h")
i = A("i")
a = B("a")
g = B("g")

d.t = n
d.v = i
l.z = b
l.t = e
l.x = d
b.x = n
b.q = h
n.x = b
n.q = a
e.z = n
e.t = l
e.x = i
h.z = n
h.t = g
h.x = i
i.t = n
i.v = d
a.z = n
a.t = h
a.x = i
g.z = n
g.t = l
g.x = d
assert l.z.q.t.z.q.t.t.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.v: A = None
        self.txt = txt

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

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

d = A("d")
l = B("l")
b = C("b")
n = C("n")
e = B("e")
h = B("h")
i = A("i")
a = B("a")
g = B("g")

d.t = n
d.v = i
l.z = b
l.t = e
l.x = d
b.x = n
b.q = h
n.x = b
n.q = a
e.z = n
e.t = l
e.x = i
h.z = n
h.t = g
h.x = i
i.t = n
i.v = d
a.z = n
a.t = h
a.x = i
g.z = n
g.t = l
g.x = d
assert l.z.q.t.z.q.t.t.x.v.txt == "i"