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

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

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

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

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

m.t = b
m.q = g
m.y = n
m.v = n
c.x = g
a.x = m
a.v = k
a.z = k
a.r = h
l.v = k
l.x = n
l.t = a
b.x = g
n.v = b
n.x = l
n.t = h
f.v = g
f.x = n
f.t = a
k.x = b
h.x = m
h.v = g
h.r = a
h.z = c
g.x = k
assert h.x.q.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.q: B = None
        self.y: D = None
        self.v: D = None
        self.txt = txt

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

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

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

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

m.t = b
m.q = g
m.y = n
m.v = n
c.x = g
a.x = m
a.v = k
a.z = k
a.r = h
l.v = k
l.x = n
l.t = a
b.x = g
n.v = b
n.x = l
n.t = h
f.v = g
f.x = n
f.t = a
k.x = b
h.x = m
h.v = g
h.r = a
h.z = c
g.x = k
assert h.x.q.x.x.x.x.txt == "k"